Skip to content

Commit

Permalink
Add result_code value for errors running ping command (influxdata#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanthjbabu authored and Jean-Louis Dupond committed Apr 22, 2019
1 parent ad05090 commit 0e070fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/inputs/ping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ urls = ["www.google.com"] # required
- result_code
- 0: success
- 1: no such host
- 2: ping error

### Tags:

Expand Down
2 changes: 2 additions & 0 deletions plugins/inputs/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 0e070fb

Please sign in to comment.