// Total number of open connections
unsigned int connections;
+ size_t bytes_received;
size_t total_bytes_received;
};
// Format total bytes received
char* total_bytes_received = format_size(stats->total_bytes_received);
+ // Calculate bandwidth
+ char* bps = format_size(stats->bytes_received / delta);
+
INFO( conf, "--- %s --------------------\n", timestamp);
DEBUG(conf, " %-20s: %19.4fs\n", "Delta", delta);
INFO( conf, " %-20s: %20u\n", "Open Connection(s)", stats->connections);
+ INFO( conf, " %-20s: %18s/s\n", "Current Bandwidth", bps);
INFO( conf, " %-20s: %20s\n", "Total Bytes Received", total_bytes_received);
// Remember when this was printed last
stats->last_printed = now;
+ // Reset statistics
+ stats->bytes_received = 0;
+
// Cleanup
+ if (bps)
+ free(bps);
+
if (total_bytes_received)
free(total_bytes_received);
DEBUG(conf, "Read %zu bytes from socket %d\n", bytes_read, fd);
// Update statistics
+ stats->bytes_received += bytes_read;
stats->total_bytes_received += bytes_read;
return 0;