diff --git a/main.go b/main.go index c28b536..e8d8c7e 100644 --- a/main.go +++ b/main.go @@ -46,19 +46,19 @@ func run() error { fmt.Printf("%s,%d,%.0f%%,%dms,%dms,%dms\n", time.Now().UTC().Format("2006-01-02T15:04:05Z"), stat.PacketsRecv, - 100.0*(1.0-stat.PacketLoss), + stat.PacketLoss, stat.MaxRtt.Milliseconds(), stat.AvgRtt.Milliseconds(), stat.StdDevRtt.Milliseconds(), ) case "json": b, _ := json.Marshal(map[string]any{ - "ts": time.Now().UTC().Format("2006-01-02T15:04:05Z"), - "n": stat.PacketsRecv, - "ok_pct": 100.0 * (1.0 - stat.PacketLoss), - "max": stat.MaxRtt.Milliseconds(), - "avg": stat.AvgRtt.Milliseconds(), - "stddev": stat.StdDevRtt.Milliseconds(), + "ts": time.Now().UTC().Format("2006-01-02T15:04:05Z"), + "n": stat.PacketsRecv, + "bad_pct": stat.PacketLoss, + "max": stat.MaxRtt.Milliseconds(), + "avg": stat.AvgRtt.Milliseconds(), + "stddev": stat.StdDevRtt.Milliseconds(), }) fmt.Printf("%s\n", b) } diff --git a/pingd b/pingd new file mode 100755 index 0000000..66eb708 Binary files /dev/null and b/pingd differ