status/scanner/icmp.go
2023-10-03 10:56:35 +00:00

18 lines
367 B
Go

package scanner
import (
"github.com/prometheus-community/pro-bing"
)
func CheckICMPUp(ctx Context, host string) (bool, string) {
pinger, err := probing.NewPinger(host)
if err != nil {
return false, err.Error()
}
pinger.Count = 1
err = pinger.RunWithContext(ctx) // blocks until finished
if err != nil {
return false, err.Error()
}
return true, "OK"
}