Skip to content

Commit

Permalink
Fix type conflict on windows ping plugin
Browse files Browse the repository at this point in the history
closes #1433
  • Loading branch information
sparrc committed Feb 22, 2017
1 parent 81408f9 commit 49cf3ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions plugins/inputs/ping/ping_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func (s *Ping) Description() string {
const sampleConfig = `
## urls to ping
urls = ["www.google.com"] # required
## number of pings to send per collection (ping -n <COUNT>)
count = 4 # required
## Ping timeout, in seconds. 0 means default timeout (ping -w <TIMEOUT>)
Timeout = 0
`
Expand All @@ -64,7 +64,7 @@ func hostPinger(timeout float64, args ...string) (string, error) {
}

// processPingOutput takes in a string output from the ping command
// based on linux implementation but using regex ( multilanguage support ) ( shouldn't affect the performance of the program )
// based on linux implementation but using regex ( multilanguage support )
// It returns (<transmitted packets>, <received reply>, <received packet>, <average response>, <min response>, <max response>)
func processPingOutput(out string) (int, int, int, int, int, int, error) {
// So find a line contain 3 numbers except reply lines
Expand Down Expand Up @@ -189,13 +189,13 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
"percent_reply_loss": lossReply,
}
if avg > 0 {
fields["average_response_ms"] = avg
fields["average_response_ms"] = float64(avg)
}
if min > 0 {
fields["minimum_response_ms"] = min
fields["minimum_response_ms"] = float64(min)
}
if max > 0 {
fields["maximum_response_ms"] = max
fields["maximum_response_ms"] = float64(max)
}
acc.AddFields("ping", fields, tags)
}(url)
Expand Down
6 changes: 3 additions & 3 deletions plugins/inputs/ping/ping_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func TestPingGather(t *testing.T) {
"reply_received": 4,
"percent_packet_loss": 0.0,
"percent_reply_loss": 0.0,
"average_response_ms": 50,
"minimum_response_ms": 50,
"maximum_response_ms": 52,
"average_response_ms": 50.0,
"minimum_response_ms": 50.0,
"maximum_response_ms": 52.0,
}
acc.AssertContainsTaggedFields(t, "ping", fields, tags)

Expand Down

0 comments on commit 49cf3ee

Please sign in to comment.