Skip to content

Commit 24f3dfb

Browse files
committed
implement status-as option to check-ping
1 parent 81d2072 commit 24f3dfb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

check-ping/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ command = ["check-ping", "-H", "127.0.0.1", "-n", "5", "-w", "100"]
4444
-H, --host= check target IP Address
4545
-n, --count= sending (and receiving) count ping packets (default: 1)
4646
-w, --wait-time= wait time, Max RTT(ms) (default: 1000)
47+
--status-as= Overwrite status=to-status, support multiple comma separetes.
4748
```
4849

4950
## For more information

check-ping/lib/check-ping.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package checkping
22

33
import (
4+
"fmt"
45
"net"
56
"os"
67
"time"
@@ -14,6 +15,7 @@ var opts struct {
1415
Host string `long:"host" short:"H" description:"check target IP Address"`
1516
Count int `long:"count" short:"n" default:"1" description:"sending (and receiving) count ping packets"`
1617
WaitTime int `long:"wait-time" short:"w" default:"1000" description:"wait time, Max RTT(ms)"`
18+
StatusAs string `long:"status-as" description:"Overwrite status=to-status, support multiple comma separetes."`
1719
}
1820

1921
func run(args []string) *checkers.Checker {
@@ -70,5 +72,10 @@ func isIPv6(host string) bool {
7072
func Do() {
7173
ckr := run(os.Args[1:])
7274
ckr.Name = "Ping"
73-
ckr.Exit()
75+
maps, err := checkers.ParseStatusMap(opts.StatusAs)
76+
if err != nil {
77+
fmt.Println(err)
78+
os.Exit(1)
79+
}
80+
ckr.ExitStatusAs(maps)
7481
}

0 commit comments

Comments
 (0)