本篇介绍两个采集插件,ping和procstat。ping监控就是用于远程探测的,年底夜莺v5最终版会内置nodata的处理逻辑,对机器的监控就不用ping了,不过有的时候,有些机器没法安装agent,这种情况可能就要考虑ping监控了。procstat主要有两个功能,一个是采集进程个数,比如nginx这种多进程模型,会采集总的进程数量,同时对每个单一进程,会采集进程相关的cpu、内存使用情况以及一些资源限制信息等。
ping
ping插件的默认配置如下:
# # Ping given url(s) and return statistics
# [[inputs.ping]]
# ## Hosts to send ping packets to.
# urls = ["example.org"]
#
# ## Method used for sending pings, can be either "exec" or "native". When set
# ## to "exec" the systems ping command will be executed. When set to "native"
# ## the plugin will send pings directly.
# ##
# ## While the default is "exec" for backwards compatibility, new deployments
# ## are encouraged to use the "native" method for improved compatibility and
# ## performance.
# # method = "exec"
#
# ## Number of ping packets to send per interval. Corresponds to the "-c"
# ## option of the ping command.
# # count = 1
#
# ## Time to wait between sending ping packets in seconds. Operates like the
# ## "-i" option of the ping command.
# # ping_interval = 1.0
#
# ## If set, the time to wait for a ping response in seconds. Operates like
# ## the "-W" option of the ping command.
# # timeout = 1.0
#
# ## If set, the total ping deadline, in seconds. Operates like the -w option
# ## of the ping command.
# # deadline = 10
#
# ## Interface or source address to send ping from. Operates like the -I or -S
# ## option of the ping command.
# # interface = ""
#
# ## Percentiles to calculate. This only works with the native method.
# # percentiles = [50, 95, 99]
#
# ## Specify the ping executable binary.
# # binary = "ping"
#
# ## Arguments for ping command. When arguments is not empty, the command from
# ## the binary option will be used and other options (ping_interval, timeout,
# ## etc) will be ignored.
# # arguments = ["-c", "3"]
#
# ## Use only IPv6 addresses when resolving a hostname.
# # ipv6 = false
urls这个字段,可以写很多ip,Telegraf就会对这些ip发起ping探测,待会咱们写一个能连通的ip,一个不能连通的ip,测试下,method有两种取值,一个是exec,就是调用