Skip to content

Commit

Permalink
Append host if arguments are specified for ping input (influxdata#5450)
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton authored and danielnelson committed Feb 19, 2019
1 parent c18934f commit e586fdb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/inputs/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugins/inputs/ping/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
}
}

Expand Down

0 comments on commit e586fdb

Please sign in to comment.