Add result_code value for errors running ping command (#4550)
This commit is contained in:
parent
d676381a04
commit
14d9ef4f0c
|
@ -39,6 +39,7 @@ urls = ["www.google.com"] # required
|
|||
- result_code
|
||||
- 0: success
|
||||
- 1: no such host
|
||||
- 2: ping error
|
||||
|
||||
### Tags:
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue