diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-10-26 14:42:05 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2015-10-29 01:10:06 +0100 |
commit | c8f47b600f8e2ad21266d4c27e960e477e5fe35c (patch) | |
tree | e8f573493b9c23e210a71eb7417d2f804357a4c3 /src | |
parent | 80db4ec3875b0de7f06de769881d6c5d4b713f2d (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/stats.c | 32 |
1 files changed, 32 insertions, 0 deletions
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 <osmocom/core/rate_ctr.h> #include <osmocom/core/stat_item.h> #include <osmocom/core/timer.h> +#include <osmocom/core/statistics.h> /* 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); |