]> git.ipfire.org Git - fireperf.git/commitdiff
stats: Show new connections per second
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Feb 2021 14:28:32 +0000 (14:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Feb 2021 14:28:32 +0000 (14:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/client.c
src/server.c

index c8ec7a1bec074989dc57bc777aa40c5a29a25830..b149c208fd52739b1c351a549248d883b26632c3 100644 (file)
@@ -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);
index 02fdeb96b4de71fa8308348f0602093b49bfa55c..2693e6c254d4247b7036395213d23df46daec5d1 100644 (file)
@@ -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) {