status/scanner/icmp.go

19 lines
367 B
Go
Raw Normal View History

2023-10-01 17:25:23 +00:00
package scanner
import (
"github.com/prometheus-community/pro-bing"
)
2023-10-03 10:56:35 +00:00
func CheckICMPUp(ctx Context, host string) (bool, string) {
2023-10-01 17:25:23 +00:00
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"
}