Skip to content

Commit

Permalink
ping plugin: use -W for linux, -t for bsd/darwin
Browse files Browse the repository at this point in the history
closes #443
  • Loading branch information
sparrc committed Feb 7, 2016
1 parent 1e03a94 commit f691e00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/inputs/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ping
import (
"errors"
"os/exec"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -133,7 +134,12 @@ func (p *Ping) args(url string) []string {
args = append(args, "-i", strconv.FormatFloat(p.PingInterval, 'f', 1, 64))
}
if p.Timeout > 0 {
args = append(args, "-t", strconv.FormatFloat(p.Timeout, 'f', 1, 64))
switch runtime.GOOS {
case "darwin", "freebsd":
args = append(args, "-t", strconv.FormatFloat(p.Timeout, 'f', 1, 64))
case "linux":
args = append(args, "-W", strconv.FormatFloat(p.Timeout, 'f', 1, 64))
}
}
if p.Interface != "" {
args = append(args, "-I", p.Interface)
Expand Down

0 comments on commit f691e00

Please sign in to comment.