ping plugin: use -W for linux, -t for bsd/darwin

closes #443
This commit is contained in:
Cameron Sparr
2016-02-02 18:43:03 -07:00
parent 1e03a9440b
commit f5f43e6d1b
2 changed files with 30 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ package ping
import (
"errors"
"os/exec"
"runtime"
"strconv"
"strings"
"sync"
@@ -133,7 +134,15 @@ 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))
default:
// Not sure the best option here, just assume GNU ping?
args = append(args, "-W", strconv.FormatFloat(p.Timeout, 'f', 1, 64))
}
}
if p.Interface != "" {
args = append(args, "-I", p.Interface)