// Format timestamp
const char* timestamp = format_timespec(&now);
- INFO( conf, "--- %s --------------------\n", timestamp);
- DEBUG(conf, " %-20s: %19.4fs\n", "Delta", delta);
- INFO( conf, " %-20s: %20u\n", "Open Connection(s)", stats->open_connections);
- INFO( conf, " %-20s: %18.2f/s\n", "New Connections", stats->connections / delta);
+ INFO(conf, "--- %s -------------------------\n", timestamp);
+ INFO(conf, " : %12s %12s\n", "RX", "TX");
+ INFO(conf, " %-20s: %25u\n", "Open Connection(s)", stats->open_connections);
+ INFO(conf, " %-20s: %23.2f/s\n", "New Connections", stats->connections / delta);
// Show current bandwidth
- char* bps = NULL;
- switch (mode) {
- case FIREPERF_MODE_CLIENT:
- bps = format_size(stats->bytes_received * 8 / delta, FIREPERF_FORMAT_BITS);
- break;
+ char* bps_received = format_size(stats->bytes_received * 8 / delta, FIREPERF_FORMAT_BITS);
+ char* bps_sent = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS);
- case FIREPERF_MODE_SERVER:
- bps = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS);
- break;
- }
+ if (bps_received || bps_sent) {
+ INFO(conf, " %-20s: %10s/s %10s/s\n", "Current Bandwidth", bps_received, bps_sent);
- if (bps) {
- INFO( conf, " %-20s: %18s/s\n", "Current Bandwidth", bps);
- free(bps);
+ if (bps_received)
+ free(bps_received);
+ if (bps_sent)
+ free(bps_sent);
}
- struct total_bytes {
- const char* label;
- size_t bytes;
- } totals[] = {
- { "Total Bytes Received", stats->total_bytes_received, },
- { "Total Bytes Sent", stats->total_bytes_sent, },
- { NULL },
- };
+ // Total bytes
+ char* total_bytes_received = format_size(stats->total_bytes_received, FIREPERF_FORMAT_BYTES);
+ char* total_bytes_sent = format_size(stats->total_bytes_sent, FIREPERF_FORMAT_BYTES);
- for (struct total_bytes* total = totals; total->label; total++) {
- if (!total->bytes)
- continue;
+ if (total_bytes_received || total_bytes_sent) {
+ INFO(conf, " %-20s: %12s %12s\n", "Total Bytes", total_bytes_received, total_bytes_sent);
- char* s = format_size(total->bytes, FIREPERF_FORMAT_BYTES);
- INFO(conf, " %-20s: %20s\n", total->label, s);
- free(s);
+ if (total_bytes_received)
+ free(total_bytes_received);
+ if (total_bytes_sent)
+ free(total_bytes_sent);
}
+ // Empty line
+ INFO(conf, "\n");
+
// Remember when this was printed last
stats->last_printed = now;