mirror of https://github.com/statping/statping
gh actions, ping command for windows
parent
2037359fad
commit
759798e1da
|
@ -5,6 +5,11 @@ on:
|
||||||
- dev
|
- dev
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
compile:
|
compile:
|
||||||
|
|
|
@ -29,14 +29,14 @@ func DirWritable(path string) (bool, error) {
|
||||||
func Ping(address string, secondsTimeout int) (int64, error) {
|
func Ping(address string, secondsTimeout int) (int64, error) {
|
||||||
ping, err := exec.LookPath("ping")
|
ping, err := exec.LookPath("ping")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return 0, err
|
||||||
}
|
}
|
||||||
out, _, err := Command(ping, address, "-n", "1", "-w", strconv.Itoa(secondsTimeout*1000))
|
out, _, err := Command(ping, address, "-n", "1", "-w", strconv.Itoa(secondsTimeout*1000))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return 0, err
|
||||||
}
|
}
|
||||||
if strings.Contains(out, "Destination Host Unreachable") {
|
if strings.Contains(out, "Destination Host Unreachable") {
|
||||||
return errors.New("destination host unreachable")
|
return 0, errors.New("destination host unreachable")
|
||||||
}
|
}
|
||||||
r := regexp.MustCompile(`Average = (.*)ms`)
|
r := regexp.MustCompile(`Average = (.*)ms`)
|
||||||
strs := r.FindStringSubmatch(out)
|
strs := r.FindStringSubmatch(out)
|
||||||
|
|
Loading…
Reference in New Issue