From eccb5c21cc752e78e4595fbe67c58ba8633f9fe0 Mon Sep 17 00:00:00 2001 From: Radha krishna Saragadam Date: Mon, 18 Jul 2022 19:50:23 +0530 Subject: stats: add loops per second counter in the stats segment. This change adds loops per second in the stats segment. Applications using the stats segment to monitor VPP can use this for better monitoring Type: fix Signed-off-by: Radha krishna Saragadam Change-Id: I53081f40ee918eec9763513a639b9d8a02488b20 --- src/vlib/stats/init.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/vlib/stats') diff --git a/src/vlib/stats/init.c b/src/vlib/stats/init.c index 16a47c2f78d..8b382daf333 100644 --- a/src/vlib/stats/init.c +++ b/src/vlib/stats/init.c @@ -8,12 +8,14 @@ #define STAT_SEGMENT_SOCKET_FILENAME "stats.sock" +static u32 vlib_loops_stats_counter_index; + static void vector_rate_collector_fn (vlib_stats_collector_data_t *d) { vlib_main_t *this_vlib_main; - counter_t **counters; - counter_t *cb; + counter_t **counters, **loops_counters; + counter_t *cb, *loops_cb; f64 vector_rate = 0.0; u32 i, n_threads = vlib_get_n_threads (); @@ -21,6 +23,11 @@ vector_rate_collector_fn (vlib_stats_collector_data_t *d) counters = d->entry->data; cb = counters[0]; + vlib_stats_validate (vlib_loops_stats_counter_index, 0, n_threads - 1); + loops_counters = + vlib_stats_get_entry_data_pointer (vlib_loops_stats_counter_index); + loops_cb = loops_counters[0]; + for (i = 0; i < n_threads; i++) { f64 this_vector_rate; @@ -28,9 +35,10 @@ vector_rate_collector_fn (vlib_stats_collector_data_t *d) this_vector_rate = vlib_internal_node_vector_rate (this_vlib_main); vlib_clear_internal_node_vector_rate (this_vlib_main); - cb[i] = this_vector_rate; vector_rate += this_vector_rate; + + loops_cb[i] = this_vlib_main->loops_per_second; } /* And set the system average rate */ @@ -115,8 +123,12 @@ vlib_stats_init (vlib_main_t *vm) reg.private_data = vlib_stats_add_gauge ("/sys/vector_rate"); reg.entry_index = vlib_stats_add_counter_vector ("/sys/vector_rate_per_worker"); + vlib_loops_stats_counter_index = + vlib_stats_add_counter_vector ("/sys/loops_per_worker"); vlib_stats_register_collector_fn (®); vlib_stats_validate (reg.entry_index, 0, vlib_get_n_threads ()); + vlib_stats_validate (vlib_loops_stats_counter_index, 0, + vlib_get_n_threads ()); return 0; } -- cgit 1.2.3-korg