Return correct response code on ping input (#4875)
This commit is contained in:
parent
cd865cfd22
commit
f10de93da4
|
@ -31,6 +31,13 @@ apt-get install iputils-ping
|
||||||
## Interface or source address to send ping from (ping -I <INTERFACE/SRC_ADDR>)
|
## Interface or source address to send ping from (ping -I <INTERFACE/SRC_ADDR>)
|
||||||
## on Darwin and Freebsd only source address possible: (ping -S <SRC_ADDR>)
|
## on Darwin and Freebsd only source address possible: (ping -S <SRC_ADDR>)
|
||||||
# interface = ""
|
# interface = ""
|
||||||
|
|
||||||
|
## Specify the ping executable binary, default is "ping"
|
||||||
|
# binary = "ping"
|
||||||
|
|
||||||
|
## Arguments for ping command
|
||||||
|
## when arguments is not empty, other options (ping_interval, timeout, etc) will be ignored
|
||||||
|
# arguments = ["-c", "3"]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Metrics:
|
### Metrics:
|
||||||
|
|
|
@ -133,6 +133,7 @@ func (p *Ping) pingToURL(u string, acc telegraf.Accumulator) {
|
||||||
if exitError, ok := err.(*exec.ExitError); ok {
|
if exitError, ok := err.(*exec.ExitError); ok {
|
||||||
if ws, ok := exitError.Sys().(syscall.WaitStatus); ok {
|
if ws, ok := exitError.Sys().(syscall.WaitStatus); ok {
|
||||||
status = ws.ExitStatus()
|
status = ws.ExitStatus()
|
||||||
|
fields["result_code"] = status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue