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
|
- result_code
|
||||||
- 0: success
|
- 0: success
|
||||||
- 1: no such host
|
- 1: no such host
|
||||||
|
- 2: ping error
|
||||||
|
|
||||||
### Tags:
|
### Tags:
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
|
||||||
} else {
|
} else {
|
||||||
acc.AddError(fmt.Errorf("host %s: %s", u, err))
|
acc.AddError(fmt.Errorf("host %s: %s", u, err))
|
||||||
}
|
}
|
||||||
|
fields["result_code"] = 2
|
||||||
acc.AddFields("ping", fields, tags)
|
acc.AddFields("ping", fields, tags)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -126,6 +127,7 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// fatal error
|
// fatal error
|
||||||
acc.AddError(fmt.Errorf("%s: %s", err, u))
|
acc.AddError(fmt.Errorf("%s: %s", err, u))
|
||||||
|
fields["result_code"] = 2
|
||||||
acc.AddFields("ping", fields, tags)
|
acc.AddFields("ping", fields, tags)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue