lsat
This commit is contained in:
8
main.go
8
main.go
@@ -34,19 +34,20 @@ func run() error {
|
||||
|
||||
switch *o {
|
||||
case "csv":
|
||||
fmt.Printf("ts,n,ok_pct,max,avg,stddev\n")
|
||||
fmt.Printf("ts,n,ok_pct,last,max,avg,stddev\n")
|
||||
case "json":
|
||||
default:
|
||||
panic(*o)
|
||||
}
|
||||
pinger.OnRecv = func(*ping.Packet) {
|
||||
pinger.OnRecv = func(packet *ping.Packet) {
|
||||
stat := pinger.Statistics()
|
||||
switch *o {
|
||||
case "csv":
|
||||
fmt.Printf("%s,%d,%.0f%%,%dms,%dms,%dms\n",
|
||||
fmt.Printf("%s,%d,%.0f%%,%dms,%dms,%dms,%dms\n",
|
||||
time.Now().UTC().Format("2006-01-02T15:04:05Z"),
|
||||
stat.PacketsRecv,
|
||||
stat.PacketLoss,
|
||||
packet.Rtt.Milliseconds(),
|
||||
stat.MaxRtt.Milliseconds(),
|
||||
stat.AvgRtt.Milliseconds(),
|
||||
stat.StdDevRtt.Milliseconds(),
|
||||
@@ -56,6 +57,7 @@ func run() error {
|
||||
"ts": time.Now().UTC().Format("2006-01-02T15:04:05Z"),
|
||||
"n": stat.PacketsRecv,
|
||||
"bad_pct": stat.PacketLoss,
|
||||
"last": packet.Rtt.Milliseconds(),
|
||||
"max": stat.MaxRtt.Milliseconds(),
|
||||
"avg": stat.AvgRtt.Milliseconds(),
|
||||
"stddev": stat.StdDevRtt.Milliseconds(),
|
||||
|
||||
Reference in New Issue
Block a user