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