mirror of
https://github.com/wahyd4/telegraf.git
synced 2026-08-13 22:58:50 +10:00
Ping Native Input Plugin
Sends a ping message and reports the results. This is done in pure go, eliminating the need to execute the system ping command.
There is currently no support for TTL on windows, track progress https://github.com/golang/go/issues/7175 and https://github.com/golang/go/issues/7174
Configuration:
[[inputs.ping_native]]
## List of hosts to ping.
hosts = ["8.8.8.8"]
## Number of pings to send per collection.
# count = 1
## Interval, in s, at which to ping.
# ping_interval = 1.0
## Per-ping timeout, in s (0 == no timeout).
# timeout = 1.0
## Total-ping deadline, in s. Set to value equal to or lower than agent interval.
# deadline = 10
## Interface or source address to send ping from.
# interface = ""
## Whether to ping ipv6 addresses.
# ipv6 = false
Permission Caveat (non Windows)
Since this plugin listens on unprivileged raw sockets on linux and darwin, the system group of the user running telegraf must be allowed to create ICMP Echo sockets. See man pages icmp(7) for ping_group_range for linux and man pages icmp(4) for `` for darwin.
sudo sysctl -w net.ipv4.ping_group_range="GROUPID GROUPID"
Metrics:
- ping
- tags:
- ip
- fields:
- packets_transmitted (integer)
- packets_received (integer)
- percent_packets_loss (float)
- ttl (integer, Not available on Windows)
- average_response_ms (integer)
- minimum_response_ms (integer)
- maximum_response_ms (integer)
- standard_deviation_ms (integer)
- result_code (int, success = 0, no such host = 1, ping error = 2)
- tags:
reply_received vs packets_received
On Windows systems, "Destination net unreachable" reply will increment packets_received but not reply_received.
Example Output:
Windows:
ping,ip=127.0.0.1 average_response_ms=94.738085,maximum_response_ms=94.790376,minimum_response_ms=94.702181,packets_received=3i,packets_transmitted=3i,percent_packet_loss=0,result_code=0i,standard_deviation_ms=0.037823 1560553382000000000
Linux:
ping,ip=2600:: average_response_ms=94.738085,maximum_response_ms=94.790376,minimum_response_ms=94.702181,packets_received=3i,packets_transmitted=3i,percent_packet_loss=0,result_code=0i,standard_deviation_ms=0.037823,ttl=52i 1560553382000000000
[agent]
interval="5s"
flush_interval="1s"
omit_hostname=true
[[outputs.file]]
[[inputs.ping_native]]
count = 3
ping_interval = 1.0
timeout = 1.0
deadline = 10
interface= "2604:a880:1:20::352:7001"
ipv6=true
hosts = [
"google.com",
"2600::",
"2620:0:ccc::2",
"2620:0:ccd::2",
]