20 lines
387 B
Go
20 lines
387 B
Go
package scanner
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prometheus-community/pro-bing"
|
|
)
|
|
|
|
func CheckICMPUp(ctx context.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"
|
|
}
|