]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
track and print accepted PPS
authorAlan T. DeKok <aland@freeradius.org>
Wed, 4 Dec 2019 14:51:26 +0000 (09:51 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 4 Dec 2019 15:12:11 +0000 (10:12 -0500)
src/lib/io/load.c
src/lib/io/load.h
src/modules/proto_radius/proto_radius_load.c

index 6a58c2829dd0b57556487e791c1eeaf3c0d0dcbf..02801234d244460b92c221f653419b3e47ea3ae6 100644 (file)
@@ -58,6 +58,7 @@ struct fr_load_s {
        fr_load_stats_t         stats;                  //!< sending statistics
        fr_time_t               step_start;             //!< when the current step started
        fr_time_t               step_end;               //!< when the current step will end
+       int                     step_received;
 
        uint32_t                pps;
        fr_time_delta_t         delta;                  //!< between packets
@@ -162,6 +163,7 @@ static void load_timer(fr_event_list_t *el, fr_time_t now, void *uctx)
        if (next >= l->step_end) {
                l->step_start = next;
                l->step_end = next + ((uint64_t) l->config->duration) * NSEC;
+               l->step_received = l->stats.received;
                l->pps += l->config->step;
                l->stats.pps = l->pps;
                l->delta = (NSEC * l->config->parallel) / l->pps;
@@ -243,6 +245,16 @@ fr_load_reply_t fr_load_generator_have_reply(fr_load_t *l, fr_time_t request_tim
        l->stats.rttvar = RTTVAR(l->stats.rtt, l->stats.rttvar, t);
        l->stats.rtt = RTT(l->stats.rtt, t);
 
+       l->stats.received++;
+
+       /*
+        *      Track packets/s.  Since times are in nanoseconds, we
+        *      have to scale the counters up by NSEC.  And since NSEC
+        *      is 1B, the calculations have to be done via 64-bit
+        *      numbers, and then converted to a final 32-bit counter.
+        */
+       l->stats.pps_accepted = (((uint64_t) (l->stats.received - l->step_received)) * NSEC) / (now - l->step_start);
+
        /*
         *      t is in nanoseconds.
         */
@@ -264,8 +276,6 @@ fr_load_reply_t fr_load_generator_have_reply(fr_load_t *l, fr_time_t request_tim
               l->stats.times[7]++; /* tens of seconds */
        }
 
-       l->stats.received++;
-
        /*
         *      Still sending packets.  Rely on the timer to send more
         *      packets.
index b564c78eacb8e95afb53b8925f0f87d258653a3a..a0cb4a32f30f8eab801f34e343994bfe8d4d4caa 100644 (file)
@@ -85,7 +85,7 @@ typedef struct {
        fr_time_delta_t rtt;            //!< smoothed round trip time
        fr_time_delta_t rttvar;         //!< RTT variation
        int             pps;            //!< current offered packets/s
-       int             pps_ema;        //!< EMA of accepted PPS
+       int             pps_accepted;   //!< Accepted PPS for the last second
        int             sent;           //!< total packets sent
        int             received;       //!< total packets received (should be == sent)
        int             backlog_ema;    //!< exponential moving average
index 1b142f95af3534a935ad8d37fe58b7f568f6ffc8..518308e2ee2c5ddbba532a1a1b2fc624644d5719 100644 (file)
@@ -293,12 +293,14 @@ static void write_stats(fr_event_list_t *el, fr_time_t now, void *uctx)
 
        len = snprintf(buffer, sizeof(buffer),
                       "%f,%f,"
-                      "%" PRIu64 ",%" PRIu64 ",%d,"
+                      "%" PRIu64 ",%" PRIu64 ","
+                      "%d,%d,"
                       "%d,%d,"
                       "%d,%d,"
                       "%d,%d,%d,%d,%d,%d,%d,%d\n",
                       now_f, last_send_f,
-                      stats->rtt, stats->rttvar, stats->pps,
+                      stats->rtt, stats->rttvar,
+                      stats->pps, stats->pps_accepted,
                       stats->sent, stats->received,
                       stats->backlog_ema, stats->max_backlog,
                       stats->times[0], stats->times[1], stats->times[2], stats->times[3],
@@ -342,7 +344,7 @@ static void mod_event_list_set(fr_listen_t *li, fr_event_list_t *el, void *nr)
 
        (void) fr_event_timer_in(thread, thread->el, &thread->ev, NSEC, write_stats, thread);
 
-       len = snprintf(buffer, sizeof(buffer), "\"time\",\"last_packet\",\"rtt\",\"rttvar\",\"pps\",\"sent\",\"received\",\"ema_backlog\",\"max_backlog\",\"usec\",\"10us\",\"100us\",\"ms\",\"10ms\",\"100ms\",\"s\",\"10s\"\n");
+       len = snprintf(buffer, sizeof(buffer), "\"time\",\"last_packet\",\"rtt\",\"rttvar\",\"pps\",\"pps_accepted\",\"sent\",\"received\",\"ema_backlog\",\"max_backlog\",\"usec\",\"10us\",\"100us\",\"ms\",\"10ms\",\"100ms\",\"s\",\"10s\"\n");
        if (write(thread->fd, buffer, len) < 0) {
                DEBUG("Failed writing to %s - %s", thread->inst->csv, fr_syserror(errno));
        }