From 25a212c2bd5675eb8c0b37325511ea36876cae00 Mon Sep 17 00:00:00 2001 From: greg linton Date: Fri, 25 Oct 2019 09:06:10 -0600 Subject: [PATCH 1/2] Fix incorrect results in ping plugin In the last change, sending to a channel was overlooked, causing all ping errors and packet sent count to be ignored. --- plugins/inputs/ping/ping.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 581d429f7b5c3..de3c5fe8fefdc 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -293,10 +293,12 @@ func (p *Ping) pingToURLNative(destination string, acc telegraf.Accumulator) { if strings.Contains(err.Error(), "not permitted") { sent.sent = false } + sents <- sent return } resps <- resp + sents <- sent }(i + 1) } } From e28cedb6097d506a5a4851f47a9f98d48d9517a9 Mon Sep 17 00:00:00 2001 From: greg linton Date: Tue, 5 Nov 2019 10:14:42 -0700 Subject: [PATCH 2/2] Test to ensure received packets are counted --- plugins/inputs/ping/ping_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/inputs/ping/ping_test.go b/plugins/inputs/ping/ping_test.go index 56303b1b23dbd..8a1a0a9e1d7ca 100644 --- a/plugins/inputs/ping/ping_test.go +++ b/plugins/inputs/ping/ping_test.go @@ -355,4 +355,5 @@ func TestPingGatherNative(t *testing.T) { assert.NoError(t, acc.GatherError(p.Gather)) assert.True(t, acc.HasPoint("ping", map[string]string{"url": "localhost"}, "packets_transmitted", 5)) + assert.True(t, acc.HasPoint("ping", map[string]string{"url": "localhost"}, "packets_received", 5)) }