From c8f47b600f8e2ad21266d4c27e960e477e5fe35c Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 14:42:05 +0100 Subject: stats: Add support for osmo_counters This commit changes the reporting code to also show all modified osmo_counter values. Since there is no grouping of these values, the name string just consists of the optional prefix and the counter name. Sponsored-by: On-Waves ehf --- src/stats.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/stats.c b/src/stats.c index 8adb6d4a..ef4be828 100644 --- a/src/stats.c +++ b/src/stats.c @@ -37,6 +37,7 @@ #include #include #include +#include /* TODO: register properly */ #define DSTATS DLGLOBAL @@ -465,10 +466,41 @@ static int stat_item_group_handler(struct stat_item_group *statg, void *sctx_) return 0; } +/*** osmo counter support ***/ + +static int handle_counter(struct osmo_counter *counter, void *sctx_) +{ + struct stats_reporter *srep; + int rc; + struct rate_ctr_desc desc = {0}; + /* Fake a rate counter description */ + desc.name = counter->name; + desc.description = counter->description; + + int delta = osmo_counter_difference(counter); + + if (delta == 0) + return 0; + + llist_for_each_entry(srep, &stats_reporter_list, list) { + if (!srep->running) + continue; + + rc = stats_reporter_send_counter(srep, NULL, &desc, + counter->value, delta); + + /* TODO: handle rc (log?, inc counter(!)?) */ + } + + return 0; +} + + /*** main reporting function ***/ int stats_report() { + osmo_counters_for_each(handle_counter, NULL); rate_ctr_for_each_group(rate_ctr_group_handler, NULL); stat_item_for_each_group(stat_item_group_handler, NULL); -- cgit v1.2.3