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("");
}
- `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
- `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.
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;
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");
}