Add result_code value for errors running ping command (#4550)

This commit is contained in:
prashanthjbabu 2018-08-24 02:20:19 +05:30 committed by Daniel Nelson
parent d676381a04
commit 14d9ef4f0c
2 changed files with 3 additions and 0 deletions

View File

@ -39,6 +39,7 @@ urls = ["www.google.com"] # required
- result_code
- 0: success
- 1: no such host
- 2: ping error
### Tags:

View File

@ -117,6 +117,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
} else {
acc.AddError(fmt.Errorf("host %s: %s", u, err))
}
fields["result_code"] = 2
acc.AddFields("ping", fields, tags)
return
}
@ -126,6 +127,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
if err != nil {
// fatal error
acc.AddError(fmt.Errorf("%s: %s", err, u))
fields["result_code"] = 2
acc.AddFields("ping", fields, tags)
return
}