]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add fr_io_stats to network && workers
authorAlan T. DeKok <aland@freeradius.org>
Fri, 20 Jul 2018 15:34:17 +0000 (11:34 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 21 Jul 2018 11:20:30 +0000 (07:20 -0400)
along with export functions

src/lib/io/network.c
src/lib/io/network.h
src/lib/io/worker.c
src/lib/io/worker.h

index f066873d65d5ad01a464651901898f09ed596ac5..fa26a011cddcabd667c336c863e1b6ecebcec931 100644 (file)
@@ -1456,3 +1456,19 @@ int fr_network_listen_inject(fr_network_t *nr, fr_listen_t *listen, uint8_t cons
 
        return fr_control_message_send(nr->control, rb, FR_CONTROL_ID_INJECT, &my_inject, sizeof(my_inject));
 }
+
+int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats)
+{
+       if (num < 0) return -1;
+       if (num == 0) return 0;
+
+       if (num >= 1) stats[0] = nr->stats.in;
+       if (num >= 2) stats[1] = nr->stats.out;
+       if (num >= 3) stats[2] = nr->stats.dup;
+       if (num >= 4) stats[3] = nr->stats.dropped;
+       if (num >= 5) stats[4] = nr->num_workers;
+
+       if (num <= 5) return num;
+
+       return 5;
+}
index 1f47fa78c95d965013754d6091829bf416b51c69..ba4757c9b96cc41f18b3f03763c6f4fab8f4bd7e 100644 (file)
@@ -44,6 +44,7 @@ int fr_network_directory_add(fr_network_t *nr, fr_listen_t const *listen) CC_HIN
 int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker) CC_HINT(nonnull);
 void fr_network_listen_read(fr_network_t *nr, fr_listen_t const *listen) CC_HINT(nonnull);
 int fr_network_listen_inject(fr_network_t *nr, fr_listen_t *listen, uint8_t const *packet, size_t packet_len, fr_time_t recv_time);
+int fr_network_stats(fr_network_t const *nr, int num, uint64_t *stats) CC_HINT(nonnull);
 
 #ifdef __cplusplus
 }
index 3044588ca649d1eb6bb9228871b7f7816ec8fcb6..27a12d5c1c2e13138b4c718b31719b47b9611be6 100644 (file)
@@ -144,9 +144,9 @@ struct fr_worker_t {
 
        fr_io_stats_t           stats;
 
-       int                     num_decoded;    //!< number of messages which have been decoded
-       int                     num_timeouts;   //!< number of messages which timed out
-       int                     num_active;     //!< number of active requests
+       uint64_t                num_decoded;    //!< number of messages which have been decoded
+       uint64_t                num_timeouts;   //!< number of messages which timed out
+       uint64_t                num_active;     //!< number of active requests
 
        fr_time_tracking_t      tracking;       //!< how much time the worker has spent doing things.
 
@@ -617,7 +617,7 @@ static void fr_worker_max_request_time(UNUSED fr_event_list_t *el, UNUSED struct
        REQUEST *request;
        fr_worker_t *worker = talloc_get_type_abort(uctx, fr_worker_t);
 
-       DEBUG2("TIMER - worker max_request_time - %d active requests", worker->num_active);
+       DEBUG2("TIMER - worker max_request_time - %" PRIu64 " active requests", worker->num_active);
 
        /*
         *      Look at the oldest requests, and see if they need to
@@ -1105,7 +1105,7 @@ static int fr_worker_pre_event(void *ctx, struct timeval *wake)
               fr_heap_num_elements(worker->runnable),
               fr_heap_num_elements(worker->localized.heap),
               fr_heap_num_elements(worker->to_decode.heap));
-       DEBUG3("\t%srequests %" PRIu64 ", decoded %d, replied %" PRIu64 " active %d",
+       DEBUG3("\t%srequests %" PRIu64 ", decoded %" PRIu64 ", replied %" PRIu64 " active %" PRIu64 "",
               worker->name, worker->stats.in, worker->num_decoded,
               worker->stats.out, worker->num_active);
 
@@ -1604,3 +1604,21 @@ static void fr_worker_verify(fr_worker_t *worker)
        }
 }
 #endif
+
+int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats)
+{
+       if (num < 0) return -1;
+       if (num == 0) return 0;
+
+       if (num >= 1) stats[0] = worker->stats.in;
+       if (num >= 2) stats[1] = worker->stats.out;
+       if (num >= 3) stats[2] = worker->stats.dup;
+       if (num >= 4) stats[3] = worker->stats.dropped;
+       if (num >= 5) stats[4] = worker->num_decoded;
+       if (num >= 6) stats[5] = worker->num_timeouts;
+       if (num >= 7) stats[6] = worker->num_active;
+
+       if (num <= 7) return num;
+
+       return 7;
+}
index ae56f5ea0b1ed18c26a94554258017451d1497a9..054e4ef6d70706e75f9559d5df2ed6459a172105 100644 (file)
@@ -53,6 +53,7 @@ void fr_worker_exit(fr_worker_t *worker) CC_HINT(nonnull);
 void fr_worker_debug(fr_worker_t *worker, FILE *fp) CC_HINT(nonnull);
 void fr_worker_name(fr_worker_t *worker, char const *name) CC_HINT(nonnull);
 fr_channel_t *fr_worker_channel_create(fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master) CC_HINT(nonnull);
+int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats) CC_HINT(nonnull);
 
 #ifdef __cplusplus
 }