]> git.gsnw.org Git - fping.git/commitdiff
JSON: rename globalSum to "stats" and avoid spaces in key names.
authorDavid Schweikert <david@schweikert.ch>
Mon, 22 Dec 2025 14:42:11 +0000 (15:42 +0100)
committerDavid Schweikert <david@schweikert.ch>
Fri, 26 Dec 2025 08:58:36 +0000 (09:58 +0100)
ci/test-16-json-output.pl
doc/fping-json.md
src/fping.c

index 849102a08256eaae5d56ee45094b2e766d2f674b..02e9fc6551ed38c9fbd4159fcd7cc492ccfc3be1 100644 (file)
@@ -180,7 +180,7 @@ $cmd->stderr_is_eq("");
 my $cmd = Test::Command->new(cmd => "fping -J -s -q -c 2 127.0.0.1");
 $cmd->exit_is_num(0);
 $cmd->stdout_like(qr/^\{"summary":\s\{"host":\s"127\.0\.0\.1",\s"xmt":\s\d+,\s"rcv":\s\d+,\s"loss":\s\d+,\s"rttMin":\s\d+\.\d+,\s"rttAvg":\s\d+\.\d+,\s"rttMax":\s\d+\.\d+\}\}
-\{"globalSum":\s\{"targets":\s\d+,\s"alive":\s\d+,\s"unreachable":\s\d+,\s"unknown\saddresses":\s\d+,\s"timeouts\s\(waiting\sfor\sresponse\)":\s\d+,\s"ICMP\sEchos\ssent":\s\d+,\s"ICMP\sEcho\sReplies\sreceived":\s\d+,\s"other\sICMP\sreceived":\s0,\s"ms\s\(min\sround\strip\stime\)":\s\d+\.\d+,\s"ms\s\(avg\sround\strip\stime\)":\s\d+\.\d+,\s"ms\s\(max\sround\strip\stime\)":\s\d+\.\d+,\s"sec\s\(elapsed\sreal\stime\)":\s\d+\.\d+\}\}?$/);
+\{"stats":\s\{"targets":\s\d+,\s"alive":\s\d+,\s"unreachable":\s\d+,\s"unknownAddresses":\s\d+,\s"timeouts":\s\d+,\s"icmpEchosSent":\s\d+,\s"icmpEchoRepliesReceived":\s\d+,\s"otherIcmpReceived":\s0,\s"rttMin":\s\d+\.\d+,\s"rttAvg":\s\d+\.\d+,\s"rttMax":\s\d+\.\d+,\s"elapsed":\s\d+\.\d+\}\}?$/);
 $cmd->stderr_is_eq("");
 }
 
index 7bc96825a3e9f5861030b6b3b3bc3c1dea67f5af..aa156cbd23cfac285728690973d57257c1314bd1 100644 (file)
@@ -53,7 +53,7 @@ JSON object:
 - `timeout`: Timeout waiting for a packet response.
 - `summary`: Summary statistics for a host (used with `-c`).
 - `vSum`: Summary of all RTT values for a host (used with `-C`).
-- `globalSum`: Global statistics for the entire run (used with `-s`).
+- `stats`: Global statistics for the entire run (used with `-s`).
 - `intSum`: Interval summary statistics (used with `-Q`).
 
 ### `resp`: Response
@@ -163,27 +163,25 @@ Generated periodically when using `-Q` (quiet with interval reporting).
 - `time`: Unix timestamp of the report.
 - Other fields are similar to `summary`.
 
-### `globalSum`: Global Summary
+### `stats`: Overall Statistics
 
 Generated at end of execution when using `-s` (stats).
 
 ```json
 {
-  "globalSum": {
+  "stats": {
     "targets": 1,
     "alive": 1,
     "unreachable": 0,
-    "unknown addresses": 0,
-    "timeouts (waiting for response)": 0,
-    "ICMP Echos sent": 5,
-    "ICMP Echo Replies received": 5,
-    "other ICMP received": 0,
-    "ms (min round trip time)": 0.045,
-    "ms (avg round trip time)": 0.062,
-    "ms (max round trip time)": 0.081,
-    "sec (elapsed real time)": 5.012
+    "unknownAddresses": 0,
+    "timeouts": 0,
+    "icmpEchosSent": 5,
+    "icmpEchoRepliesReceived": 5,
+    "otherIcmpReceived": 0,
+    "rttMin": 0.045,
+    "rttAvg": 0.062,
+    "rttMax": 0.081,
+    "elapsed": 5.012
   }
 }
 ```
-
-Contains aggregate statistics for the entire fping run.
index 5ca1ec938fcfebba08788d2182e2d6554ca53f72..965b946fff3c313dbd1bb1365e4a254f3a4f4310 100644 (file)
@@ -2608,15 +2608,15 @@ void print_global_stats(void)
 
 void print_global_stats_json(void)
 {
-    fprintf(stdout, "{\"globalSum\": {");
+    fprintf(stdout, "{\"stats\": {");
     fprintf(stdout, "\"targets\": %d, ", num_hosts);
     fprintf(stdout, "\"alive\": %d, ", num_alive);
     fprintf(stdout, "\"unreachable\": %d, ", num_unreachable);
-    fprintf(stdout, "\"unknown addresses\": %d, ", num_noaddress);
-    fprintf(stdout, "\"timeouts (waiting for response)\": %d, ", num_timeout);
-    fprintf(stdout, "\"ICMP Echos sent\": %d, ", num_pingsent);
-    fprintf(stdout, "\"ICMP Echo Replies received\": %d, ", num_pingreceived);
-    fprintf(stdout, "\"other ICMP received\": %d, ", num_othericmprcvd);
+    fprintf(stdout, "\"unknownAddresses\": %d, ", num_noaddress);
+    fprintf(stdout, "\"timeouts\": %d, ", num_timeout);
+    fprintf(stdout, "\"icmpEchosSent\": %d, ", num_pingsent);
+    fprintf(stdout, "\"icmpEchoRepliesReceived\": %d, ", num_pingreceived);
+    fprintf(stdout, "\"otherIcmpReceived\": %d, ", num_othericmprcvd);
 
     if (total_replies == 0) {
         min_reply = 0;
@@ -2625,10 +2625,10 @@ void print_global_stats_json(void)
         sum_replies = 0;
     }
 
-    fprintf(stdout, "\"ms (min round trip time)\": %s, ", sprint_tm(min_reply));
-    fprintf(stdout, "\"ms (avg round trip time)\": %s, ", sprint_tm(sum_replies / total_replies));
-    fprintf(stdout, "\"ms (max round trip time)\": %s, ", sprint_tm(max_reply));
-    fprintf(stdout, "\"sec (elapsed real time)\": %.3f", (end_time - start_time) / 1e9);
+    fprintf(stdout, "\"rttMin\": %s, ", sprint_tm(min_reply));
+    fprintf(stdout, "\"rttAvg\": %s, ", sprint_tm(sum_replies / total_replies));
+    fprintf(stdout, "\"rttMax\": %s, ", sprint_tm(max_reply));
+    fprintf(stdout, "\"elapsed\": %.3f", (end_time - start_time) / 1e9);
     fprintf(stdout, "}}\n");
 }