Don't compile ping plugin on windows.

closes #496
This commit is contained in:
Cameron Sparr 2016-02-01 16:36:08 -07:00
parent 331b700d1b
commit d266dad1f4
3 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,5 @@
// +build !windows
package ping
import (
@ -41,6 +43,9 @@ func (_ *Ping) Description() string {
}
var sampleConfig = `
# NOTE: this plugin forks the ping command. You may need to set capabilities
# via setcap cap_net_raw+p /bin/ping
# urls to ping
urls = ["www.google.com"] # required
# number of pings to send (ping -c <COUNT>)
@ -111,7 +116,11 @@ func (p *Ping) Gather(acc telegraf.Accumulator) error {
}
func hostPinger(args ...string) (string, error) {
c := exec.Command("ping", args...)
bin, err := exec.LookPath("ping")
if err != nil {
return "", err
}
c := exec.Command(bin, args...)
out, err := c.CombinedOutput()
return string(out), err
}

View File

@ -1,3 +1,5 @@
// +build !windows
package ping
import (

View File

@ -0,0 +1,3 @@
// +build windows
package ping