summaryrefslogtreecommitdiffstats
path: root/src/stats.c
diff options
context:
space:
mode:
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);
}