From 3cc1fecb535b306b865d82711ec58a153821160b Mon Sep 17 00:00:00 2001 From: Thibault Cohen Date: Mon, 11 Jan 2016 17:19:21 -0500 Subject: [PATCH] Ping input doesn't return response time metric when timeout closes #506 --- CHANGELOG.md | 10 +++++++++- plugins/inputs/ping/ping.go | 4 +++- plugins/inputs/ping/ping_test.go | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b944c6ac3..1b398d00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -## v0.10.0 [unreleased] +## v0.10.1 [unreleased] + +### Features +- [#509](https://github.com/influxdb/telegraf/pull/509): Flatten JSON arrays with indices. Thanks @psilva261! + +### Bugfixes +- [#506](https://github.com/influxdb/telegraf/pull/506): Ping input doesn't return response time metric when timeout. Thanks @titilambert! + +## v0.10.0 [2014-01-12] ### Release Notes - Linux packages have been taken out of `opt`, the binary is now in `/usr/bin` diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index e03fc71e8..ff7cebb99 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -86,7 +86,9 @@ func (p *Ping) Gather(acc inputs.Accumulator) error { "packets_transmitted": trans, "packets_received": rec, "percent_packet_loss": loss, - "average_response_ms": avg, + } + if avg > 0 { + fields["average_response_ms"] = avg } acc.AddFields("ping", fields, tags) }(url, acc) diff --git a/plugins/inputs/ping/ping_test.go b/plugins/inputs/ping/ping_test.go index 7ae86534d..b98a08be8 100644 --- a/plugins/inputs/ping/ping_test.go +++ b/plugins/inputs/ping/ping_test.go @@ -193,7 +193,6 @@ func TestBadPingGather(t *testing.T) { "packets_transmitted": 2, "packets_received": 0, "percent_packet_loss": 100.0, - "average_response_ms": 0.0, } acc.AssertContainsTaggedFields(t, "ping", fields, tags) }