aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2020-07-14 18:11:14 +0200
committerlaforge <laforge@osmocom.org>2020-07-17 16:41:31 +0000
commit1a1de33bf99c950f1414565c287e49b26e8c4217 (patch)
tree465d896edabc5e9a4ba502a9f4ec60d96ded0530 /src/vty
parentea71b439ec3c9ba1e39174972664be4c2f62a0ca (diff)
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
Diffstat (limited to 'src/vty')
-rw-r--r--src/vty/stats_vty.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index 46282817..1483eaa5 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -43,6 +43,8 @@
#define SHOW_STATS_STR "Show statistical values\n"
+#define STATS_STR "Stats related commands\n"
+
/*! \file stats_vty.c
* VTY interface for statsd / statistic items
*
@@ -351,9 +353,9 @@ DEFUN(cfg_no_stats_reporter_log, cfg_no_stats_reporter_log_cmd,
}
DEFUN(cfg_stats_interval, cfg_stats_interval_cmd,
- "stats interval <1-65535>",
+ "stats interval <0-65535>",
CFG_STATS_STR "Set the reporting interval\n"
- "Interval in seconds\n")
+ "Interval in seconds (0 disables the reporting interval)\n")
{
int rc;
int interval = atoi(argv[0]);
@@ -567,6 +569,37 @@ DEFUN(show_rate_counters,
return CMD_SUCCESS;
}
+DEFUN(stats_report,
+ stats_report_cmd,
+ "stats report",
+ STATS_STR "Manurally trigger reporting of stats\n")
+{
+ osmo_stats_report();
+ return CMD_SUCCESS;
+}
+
+static int reset_rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_)
+{
+ rate_ctr_group_reset(ctrg);
+ return 0;
+}
+
+static int reset_osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
+{
+ osmo_stat_item_group_reset(statg);
+ return 0;
+}
+
+DEFUN(stats_reset,
+ stats_reset_cmd,
+ "stats reset",
+ STATS_STR "Reset all stats\n")
+{
+ rate_ctr_for_each_group(reset_rate_ctr_group_handler, NULL);
+ osmo_stat_item_for_each_group(reset_osmo_stat_item_group_handler, NULL);
+ return CMD_SUCCESS;
+}
+
static int config_write_stats_reporter(struct vty *vty, struct osmo_stats_reporter *srep)
{
if (srep == NULL)
@@ -666,4 +699,7 @@ void osmo_stats_vty_add_cmds()
install_element_ve(&show_stats_asciidoc_table_cmd);
install_element_ve(&show_rate_counters_cmd);
+
+ install_element(ENABLE_NODE, &stats_report_cmd);
+ install_element(ENABLE_NODE, &stats_reset_cmd);
}