diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index e29a28c56..b6baa7d99 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -140,7 +140,7 @@ func (p *Ping) args(url string) []string { if p.Timeout > 0 { switch runtime.GOOS { case "darwin": - args = append(args, "-W", strconv.FormatFloat(p.Timeout/1000, 'f', 1, 64)) + args = append(args, "-W", strconv.FormatFloat(p.Timeout*1000, 'f', 1, 64)) case "linux": args = append(args, "-W", strconv.FormatFloat(p.Timeout, 'f', 1, 64)) default: diff --git a/plugins/inputs/ping/ping_test.go b/plugins/inputs/ping/ping_test.go index 25ecdf2fa..b5d0d16e7 100644 --- a/plugins/inputs/ping/ping_test.go +++ b/plugins/inputs/ping/ping_test.go @@ -95,7 +95,10 @@ func TestArgs(t *testing.T) { p.Timeout = 12.0 actual = p.args("www.google.com") switch runtime.GOOS { - case "darwin", "freebsd": + case "darwin": + expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-W", + "12000.0", "www.google.com"} + case "freebsd": expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t", "12.0", "www.google.com"} default: @@ -111,7 +114,10 @@ func TestArgs(t *testing.T) { p.PingInterval = 1.2 actual = p.args("www.google.com") switch runtime.GOOS { - case "darwin", "freebsd": + case "darwin": + expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-W", + "12000.0", "-i", "1.2", "www.google.com"} + case "freebsd": expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t", "12.0", "-i", "1.2", "www.google.com"} default: