diff --git a/plugins/inputs/ping/ping.go b/plugins/inputs/ping/ping.go index 1d49cccc4..69db140ae 100644 --- a/plugins/inputs/ping/ping.go +++ b/plugins/inputs/ping/ping.go @@ -193,7 +193,7 @@ func hostPinger(binary string, timeout float64, args ...string) (string, error) // args returns the arguments for the 'ping' executable func (p *Ping) args(url string, system string) []string { if len(p.Arguments) > 0 { - return p.Arguments + return append(p.Arguments, url) } // build the ping command args based on toml config diff --git a/plugins/inputs/ping/ping_test.go b/plugins/inputs/ping/ping_test.go index 867220b20..ad6fa306a 100644 --- a/plugins/inputs/ping/ping_test.go +++ b/plugins/inputs/ping/ping_test.go @@ -126,6 +126,7 @@ func TestArgs(t *testing.T) { func TestArguments(t *testing.T) { arguments := []string{"-c", "3"} + expected := append(arguments, "www.google.com") p := Ping{ Count: 2, Interface: "eth0", @@ -137,7 +138,7 @@ func TestArguments(t *testing.T) { for _, system := range []string{"darwin", "linux", "anything else"} { actual := p.args("www.google.com", system) - require.True(t, reflect.DeepEqual(actual, arguments), "Expected: %s Actual: %s", arguments, actual) + require.True(t, reflect.DeepEqual(actual, expected), "Expected: %s Actual: %s", expected, actual) } }