diff --git a/plugins/inputs/ping/README.md b/plugins/inputs/ping/README.md index eadc60ab7..846430a44 100644 --- a/plugins/inputs/ping/README.md +++ b/plugins/inputs/ping/README.md @@ -39,6 +39,7 @@ urls = ["www.google.com"] # required - result_code - 0: success - 1: no such host + - 2: ping error ### Tags: diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 7ddbf275e..46afb206a 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -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 }