From: Michael Tremer Date: Thu, 4 Feb 2021 14:28:32 +0000 (+0000) Subject: stats: Show new connections per second X-Git-Tag: 0.1.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86ce04603549ba79409e83958b70952bf6bf03e8;p=fireperf.git stats: Show new connections per second Signed-off-by: Michael Tremer --- diff --git a/src/client.c b/src/client.c index c8ec7a1..b149c20 100644 --- a/src/client.c +++ b/src/client.c @@ -39,6 +39,9 @@ struct fireperf_client_stats { // Total number of open connections unsigned int open_connections; + // New connections + unsigned int connections; + size_t bytes_sent; size_t total_bytes_sent; }; @@ -133,6 +136,7 @@ static int dump_stats(struct fireperf_config* conf, struct fireperf_client_stats char* bps = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS); INFO(conf, "--- %s --------------------\n", timestamp); + INFO(conf, " %-20s: %16.2f/s\n", "New Connections", stats->connections / delta); INFO(conf, " %-20s: %18s/s\n", "Current Bandwidth", bps); INFO(conf, " %-20s: %20s\n", "Total Bytes Sent", total_bytes_sent); @@ -140,6 +144,7 @@ static int dump_stats(struct fireperf_config* conf, struct fireperf_client_stats stats->last_printed = now; // Reset statistics + stats->connections = 0; stats->bytes_sent = 0; // Cleanup @@ -319,6 +324,7 @@ int fireperf_client(struct fireperf_config* conf, int epollfd, int timerfd) { } stats.open_connections++; + stats.connections++; } int fds = epoll_wait(epollfd, events, EPOLL_MAX_EVENTS, -1); diff --git a/src/server.c b/src/server.c index 02fdeb9..2693e6c 100644 --- a/src/server.c +++ b/src/server.c @@ -40,6 +40,9 @@ struct fireperf_server_stats { // Total number of open connections unsigned int open_connections; + // New connections + unsigned int connections; + size_t bytes_received; size_t total_bytes_received; }; @@ -72,6 +75,7 @@ static int dump_stats(struct fireperf_config* conf, struct fireperf_server_stats 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: %16.2f/s\n", "New Connections", stats->connections / delta); INFO( conf, " %-20s: %18s/s\n", "Current Bandwidth", bps); INFO( conf, " %-20s: %20s\n", "Total Bytes Received", total_bytes_received); @@ -79,6 +83,7 @@ static int dump_stats(struct fireperf_config* conf, struct fireperf_server_stats stats->last_printed = now; // Reset statistics + stats->connections = 0; stats->bytes_received = 0; // Cleanup @@ -258,6 +263,7 @@ int fireperf_server(struct fireperf_config* conf, int epollfd, int timerfd) { // A connection has been opened stats.open_connections++; + stats.connections++; // Handle timer events } else if (fd == timerfd) {