aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/stats_vty.c
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2020-05-08 19:10:40 +0300
committerlaforge <laforge@osmocom.org>2020-05-09 08:08:53 +0000
commitdfebf405e59abd1ce8a4ee755908079bacb2cd4a (patch)
tree232fcb56bb0e2d7216cb03a888b72019cc9382e4 /src/vty/stats_vty.c
parentf203ed3add7efc917758b081758c61fef2fdb4b7 (diff)
stats: Support regular stats flush
Reliable monitoring requires regular flush of all stat values, even if they have not changed. Otherwise (1) the monitoring app has to maintain state and (2) can go out of sync if it's restarted while the app is still running. Change-Id: I04f1e7bdf0d6f20e4f15571e94191de61c47ddad
Diffstat (limited to 'src/vty/stats_vty.c')
-rw-r--r--src/vty/stats_vty.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index a512703f..46282817 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -245,6 +245,27 @@ DEFUN(cfg_stats_reporter_disable, cfg_stats_reporter_disable_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_stats_reporter_flush_period, cfg_stats_reporter_flush_period_cmd,
+ "flush-period <0-65535>",
+ CFG_STATS_STR "Send all stats even if they have not changed (i.e. force the flush)"
+ "every N-th reporting interval. Set to 0 to disable regular flush (default).\n"
+ "0 to disable regular flush (default), 1 to flush every time, 2 to flush every 2nd time, etc\n")
+{
+ int rc;
+ unsigned int period = atoi(argv[0]);
+ struct osmo_stats_reporter *srep = osmo_stats_vty2srep(vty);
+ OSMO_ASSERT(srep);
+
+ rc = osmo_stats_reporter_set_flush_period(srep, period);
+ if (rc < 0) {
+ vty_out(vty, "%% Unable to set force flush period: %s%s",
+ strerror(-rc), VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_stats_reporter_statsd, cfg_stats_reporter_statsd_cmd,
"stats reporter statsd",
CFG_STATS_STR CFG_REPORTER_STR "Report to a STATSD server\n")
@@ -588,6 +609,10 @@ static int config_write_stats_reporter(struct vty *vty, struct osmo_stats_report
else
vty_out(vty, " no prefix%s", VTY_NEWLINE);
+ if (srep->flush_period > 0)
+ vty_out(vty, " flush-period %d%s",
+ srep->flush_period, VTY_NEWLINE);
+
if (srep->enabled)
vty_out(vty, " enable%s", VTY_NEWLINE);
@@ -637,6 +662,7 @@ void osmo_stats_vty_add_cmds()
install_element(CFG_STATS_NODE, &cfg_stats_reporter_level_cmd);
install_element(CFG_STATS_NODE, &cfg_stats_reporter_enable_cmd);
install_element(CFG_STATS_NODE, &cfg_stats_reporter_disable_cmd);
+ install_element(CFG_STATS_NODE, &cfg_stats_reporter_flush_period_cmd);
install_element_ve(&show_stats_asciidoc_table_cmd);
install_element_ve(&show_rate_counters_cmd);