Try ping plugin with -n and -s options added

This commit is contained in:
Cameron Sparr 2016-02-01 18:32:01 -07:00
parent 9a59512f75
commit 1e03a9440b
3 changed files with 7 additions and 5 deletions

View File

@ -128,7 +128,7 @@ func hostPinger(args ...string) (string, error) {
// args returns the arguments for the 'ping' executable // args returns the arguments for the 'ping' executable
func (p *Ping) args(url string) []string { func (p *Ping) args(url string) []string {
// Build the ping command args based on toml config // Build the ping command args based on toml config
args := []string{"-c", strconv.Itoa(p.Count)} args := []string{"-c", strconv.Itoa(p.Count), "-n", "-s", "16"}
if p.PingInterval > 0 { if p.PingInterval > 0 {
args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', 1, 64)) args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', 1, 64))
} }

View File

@ -76,7 +76,7 @@ func TestArgs(t *testing.T) {
// Actual and Expected arg lists must be sorted for reflect.DeepEqual // Actual and Expected arg lists must be sorted for reflect.DeepEqual
actual := p.args("www.google.com") actual := p.args("www.google.com")
expected := []string{"-c", "2", "www.google.com"} expected := []string{"-c", "2", "-n", "-s", "16", "www.google.com"}
sort.Strings(actual) sort.Strings(actual)
sort.Strings(expected) sort.Strings(expected)
assert.True(t, reflect.DeepEqual(expected, actual), assert.True(t, reflect.DeepEqual(expected, actual),
@ -84,7 +84,7 @@ func TestArgs(t *testing.T) {
p.Interface = "eth0" p.Interface = "eth0"
actual = p.args("www.google.com") actual = p.args("www.google.com")
expected = []string{"-c", "2", "-I", "eth0", "www.google.com"} expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "www.google.com"}
sort.Strings(actual) sort.Strings(actual)
sort.Strings(expected) sort.Strings(expected)
assert.True(t, reflect.DeepEqual(expected, actual), assert.True(t, reflect.DeepEqual(expected, actual),
@ -92,7 +92,7 @@ func TestArgs(t *testing.T) {
p.Timeout = 12.0 p.Timeout = 12.0
actual = p.args("www.google.com") actual = p.args("www.google.com")
expected = []string{"-c", "2", "-I", "eth0", "-t", "12.0", "www.google.com"} expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t", "12.0", "www.google.com"}
sort.Strings(actual) sort.Strings(actual)
sort.Strings(expected) sort.Strings(expected)
assert.True(t, reflect.DeepEqual(expected, actual), assert.True(t, reflect.DeepEqual(expected, actual),
@ -100,7 +100,7 @@ func TestArgs(t *testing.T) {
p.PingInterval = 1.2 p.PingInterval = 1.2
actual = p.args("www.google.com") actual = p.args("www.google.com")
expected = []string{"-c", "2", "-I", "eth0", "-t", "12.0", "-i", "1.2", expected = []string{"-c", "2", "-n", "-s", "16", "-I", "eth0", "-t", "12.0", "-i", "1.2",
"www.google.com"} "www.google.com"}
sort.Strings(actual) sort.Strings(actual)
sort.Strings(expected) sort.Strings(expected)

View File

@ -68,4 +68,6 @@ tmpdir=$(mktemp -d)
exit_if_fail ./telegraf -config $tmpdir/config.toml \ exit_if_fail ./telegraf -config $tmpdir/config.toml \
-test -input-filter cpu:mem -test -input-filter cpu:mem
mv ./telegraf $CIRCLE_ARTIFACTS
exit $rc exit $rc