aboutsummaryrefslogtreecommitdiffstats
path: root/src/stats.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-11-02 14:49:35 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-11-02 15:39:31 +0100
commitbc9d9aced8c174bbb5fc265ec746621d31344be0 (patch)
treeb5dc1666da0f145b9239e9a8be1e0dac1db4d8ec /src/stats.c
parent16fe8dab7c1fede87f6bdbfbbcbf19f64d60648a (diff)
stats: Limit reporting by class id
This commit adds class_id fields to the rate_ctr and stat_item group descriptions. The stats reporter code is extended to only process groups whose class_id does not exceed a per reporter max_class level. If the class_id is not set, the code assumes 'global' for groups with idx == 0 and 'subscriber' otherwise. The following vty command is added to config-stats: level (global|peer|subscriber) Set the maximum group level Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/stats.c')
-rw-r--r--src/stats.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/stats.c b/src/stats.c
index 4d5a1f57..bdb0fbe6 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -254,6 +254,17 @@ int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
return update_srep_config(srep);
}
+int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep,
+ enum osmo_stats_class class_id)
+{
+ if (class_id == OSMO_STATS_CLASS_UNKNOWN)
+ return -EINVAL;
+
+ srep->max_class = class_id;
+
+ return 0;
+}
+
int osmo_stats_set_interval(int interval)
{
if (interval <= 0)
@@ -317,6 +328,16 @@ static int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
return rc;
}
+static int osmo_stats_reporter_check_config(struct osmo_stats_reporter *srep,
+ unsigned int index, int class_id)
+{
+ if (class_id == OSMO_STATS_CLASS_UNKNOWN)
+ class_id = index != 0 ?
+ OSMO_STATS_CLASS_SUBSCRIBER : OSMO_STATS_CLASS_GLOBAL;
+
+ return class_id <= srep->max_class;
+}
+
/*** log reporter ***/
struct osmo_stats_reporter *osmo_stats_reporter_create_log(const char *name)
@@ -559,6 +580,10 @@ static int rate_ctr_handler(
if (!srep->running)
continue;
+ if (!osmo_stats_reporter_check_config(srep,
+ ctrg->idx, ctrg->desc->class_id))
+ return 0;
+
rc = osmo_stats_reporter_send_counter(srep, ctrg, desc,
ctr->current, delta);
@@ -601,6 +626,10 @@ static int osmo_stat_item_handler(
if (!srep->running)
continue;
+ if (!osmo_stats_reporter_check_config(srep,
+ statg->idx, statg->desc->class_id))
+ return 0;
+
rc = osmo_stats_reporter_send_item(srep, statg,
item->desc, value);
}