stats: Add stats commands related to testing
* Allow to set the reporting interval to 0 for manual reporting
* stats reset command to reset all statistics
* stats report command to manually trigger statistics reporting
Change-Id: I9febcb65650abfd538caedfbca77a787e66d517a
Related: SYS#4877
diff --git a/src/stats.c b/src/stats.c
index a5a4d4b..c91a978 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -181,12 +181,21 @@
if (rc < 0)
LOGP(DLSTATS, LOGL_ERROR, "Failed to setup the timer with error code %d (fd=%d)\n",
rc, osmo_stats_timer.fd);
- rc = osmo_timerfd_schedule(&osmo_stats_timer, &ts_first, &ts_interval);
- if (rc < 0)
- LOGP(DLSTATS, LOGL_ERROR, "Failed to schedule the timer with error code %d (fd=%d, interval %d sec)\n",
- rc, osmo_stats_timer.fd, interval);
- LOGP(DLSTATS, LOGL_INFO, "Stats timer started with interval %d sec\n", interval);
+ if (interval == 0) {
+ rc = osmo_timerfd_disable(&osmo_stats_timer);
+ if (rc < 0)
+ LOGP(DLSTATS, LOGL_ERROR, "Failed to disable the timer with error code %d (fd=%d)\n",
+ rc, osmo_stats_timer.fd);
+ } else {
+
+ rc = osmo_timerfd_schedule(&osmo_stats_timer, &ts_first, &ts_interval);
+ if (rc < 0)
+ LOGP(DLSTATS, LOGL_ERROR, "Failed to schedule the timer with error code %d (fd=%d, interval %d sec)\n",
+ rc, osmo_stats_timer.fd, interval);
+
+ LOGP(DLSTATS, LOGL_INFO, "Stats timer started with interval %d sec\n", interval);
+ }
return 0;
}
@@ -361,7 +370,7 @@
* \returns 0 on success; negative on error */
int osmo_stats_set_interval(int interval)
{
- if (interval <= 0)
+ if (interval < 0)
return -EINVAL;
osmo_stats_config->interval = interval;