This commit is contained in:
Bel LaPointe
2026-06-08 13:10:29 -07:00
parent 8e202a0381
commit 3a5819007f
2 changed files with 5 additions and 3 deletions

View File

@@ -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(),