telegraf/plugins/inputs/ping/README.md

175 lines
5.3 KiB
Markdown
Raw Normal View History

2018-08-31 20:59:30 +00:00
# Ping Input Plugin
2018-08-31 20:59:30 +00:00
Sends a ping message by executing the system ping command and reports the results.
2019-09-20 23:49:14 +00:00
This plugin has two main methods of operation: `exec` and `native`. The
recommended method is `native`, which has greater system compatibility and
performance. However, for backwards compatibility the `exec` method is the
default.
When using `method = "exec"`, the systems ping utility is executed to send the
ping packets.
2019-04-08 22:42:28 +00:00
Most ping command implementations are supported, one notable exception being
2019-09-20 23:49:14 +00:00
that there is currently no support for GNU Inetutils ping. You may instead use
the iputils-ping implementation:
2018-08-31 20:59:30 +00:00
```
apt-get install iputils-ping
```
2019-09-20 23:49:14 +00:00
When using `method = "native"` a ping is sent and the results are reported in
native Go by the Telegraf process, eliminating the need to execute the system
`ping` command.
2016-12-14 19:47:48 +00:00
### Configuration:
2018-08-31 20:59:30 +00:00
```toml
[[inputs.ping]]
2019-09-20 23:49:14 +00:00
## Hosts to send ping packets to.
2018-08-31 20:59:30 +00:00
urls = ["example.org"]
2019-09-20 23:49:14 +00:00
## 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.
2018-08-31 20:59:30 +00:00
# count = 1
2019-09-20 23:49:14 +00:00
## Time to wait between sending ping packets in seconds. Operates like the
## "-i" option of the ping command.
2018-08-31 20:59:30 +00:00
# ping_interval = 1.0
2019-09-20 23:49:14 +00:00
## If set, the time to wait for a ping response in seconds. Operates like
## the "-W" option of the ping command.
2018-08-31 20:59:30 +00:00
# timeout = 1.0
2019-09-20 23:49:14 +00:00
## If set, the total ping deadline, in seconds. Operates like the -w option
## of the ping command.
2018-08-31 20:59:30 +00:00
# deadline = 10
2019-09-20 23:49:14 +00:00
## Interface or source address to send ping from. Operates like the -I or -S
## option of the ping command.
2018-08-31 20:59:30 +00:00
# interface = ""
2019-09-20 23:49:14 +00:00
## Specify the ping executable binary.
# binary = "ping"
2019-09-20 23:49:14 +00:00
## 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"]
2019-09-20 23:49:14 +00:00
## Use only IPv6 addresses when resolving a hostname.
# ipv6 = false
```
#### File Limit
2019-09-20 23:49:14 +00:00
Since this plugin runs the ping command, it may need to open multiple files per
host. The number of files used is lessened with the `native` option but still
many files are used. With a large host list you may receive a `too many open
files` error.
2019-09-20 23:49:14 +00:00
To increase this limit on platforms using systemd the recommended method is to
use the "drop-in directory", usually located at
`/etc/systemd/system/telegraf.service.d`.
2019-09-20 23:49:14 +00:00
You can create or edit a drop-in file in the correct location using:
```sh
$ systemctl edit telegraf
```
2019-09-20 23:49:14 +00:00
Increase the number of open files:
```ini
[Service]
LimitNOFILE=8192
```
2019-09-20 23:49:14 +00:00
Restart Telegraf:
```sh
$ systemctl edit telegraf
```
2019-09-20 23:49:14 +00:00
#### Linux Permissions
When using `method = "native"`, Telegraf will attempt to use privileged raw
ICMP sockets. On most systems, doing so requires `CAP_NET_RAW` capabilities.
With systemd:
```sh
$ systemctl edit telegraf
```
2019-09-20 23:49:14 +00:00
```ini
[Service]
2019-09-20 23:49:14 +00:00
CapabilityBoundingSet=CAP_NET_RAW
AmbientCapabilities=CAP_NET_RAW
```
```sh
$ systemctl restart telegraf
```
2019-09-20 23:49:14 +00:00
Without systemd:
```sh
$ setcap cap_net_raw=eip /usr/bin/telegraf
```
2019-09-20 23:49:14 +00:00
Reference [`man 7 capabilities`][man 7 capabilities] for more information about
setting capabilities.
2019-09-20 23:49:14 +00:00
[man 7 capabilities]: http://man7.org/linux/man-pages/man7/capabilities.7.html
2019-09-20 23:49:14 +00:00
When Telegraf cannot listen on a privileged ICMP socket it will attempt to use
ICMP echo sockets. If you wish to use this method you must ensure Telegraf's
group, usually `telegraf`, is allowed to use ICMP echo sockets:
2019-09-20 23:49:14 +00:00
```sh
$ sysctl -w net.ipv4.ping_group_range="GROUP_ID_LOW GROUP_ID_HIGH"
```
2019-09-20 23:49:14 +00:00
Reference [`man 7 icmp`][man 7 icmp] for more information about ICMP echo
sockets and the `ping_group_range` setting.
[man 7 icmp]: http://man7.org/linux/man-pages/man7/icmp.7.html
2019-09-20 23:49:14 +00:00
### Metrics
2018-08-31 20:59:30 +00:00
- ping
- tags:
- url
- fields:
- packets_transmitted (integer)
- packets_received (integer)
- percent_packets_loss (float)
2019-03-08 22:30:38 +00:00
- ttl (integer, Not available on Windows)
2018-08-31 20:59:30 +00:00
- average_response_ms (integer)
- minimum_response_ms (integer)
- maximum_response_ms (integer)
- standard_deviation_ms (integer, Available on Windows only with native ping)
2018-08-31 20:59:30 +00:00
- errors (float, Windows only)
2019-09-20 23:49:14 +00:00
- reply_received (integer, Windows with method = "exec" only)
- percent_reply_loss (float, Windows with method = "exec" only)
2018-08-31 20:59:30 +00:00
- result_code (int, success = 0, no such host = 1, ping error = 2)
2018-08-31 20:59:30 +00:00
##### reply_received vs packets_received
2019-09-20 23:49:14 +00:00
On Windows systems with `method = "exec"`, the "Destination net unreachable" reply will increment `packets_received` but not `reply_received`*.
2019-09-20 23:49:14 +00:00
##### ttl
There is currently no support for TTL on windows with `"native"`; track
progress at https://github.com/golang/go/issues/7175 and
https://github.com/golang/go/issues/7174
2018-08-31 20:59:30 +00:00
2019-09-20 23:49:14 +00:00
### Example Output
```
2019-03-08 22:30:38 +00:00
ping,url=example.org average_response_ms=23.066,ttl=63,maximum_response_ms=24.64,minimum_response_ms=22.451,packets_received=5i,packets_transmitted=5i,percent_packet_loss=0,result_code=0i,standard_deviation_ms=0.809 1535747258000000000
2016-12-14 19:47:48 +00:00
```