summaryrefslogtreecommitdiffstats
path: root/src/vlib/stats/init.c
diff options
context:
space:
mode:
authorRadha krishna Saragadam <krishna_srk2003@yahoo.com>2022-07-18 19:50:23 +0530
committerFlorin Coras <florin.coras@gmail.com>2022-07-19 20:37:55 +0000
commiteccb5c21cc752e78e4595fbe67c58ba8633f9fe0 (patch)
treeb6a2fc4ac144b817a2445be498aa98680ea6df27 /src/vlib/stats/init.c
parentadd763797fb7951a82600f9ecb837b2f7b205660 (diff)
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 <krishna_srk2003@yahoo.com> Change-Id: I53081f40ee918eec9763513a639b9d8a02488b20
Diffstat (limited to 'src/vlib/stats/init.c')
-rw-r--r--src/vlib/stats/init.c18
1 files changed, 15 insertions, 3 deletions
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 (&reg);
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;
}