stats/vty: Add selective show stats command
Currently there is only the 'show stats' command which shows all
counter and stat_item values. This can lead to many lines of output
if there are per-subscriber rate counters.
The new command added by this commit allows it to only show groups of
a certain level (class_id), similar to the 'level' configuration
command for stats reporter.
The new command is
show stats level (global|peer|subscriber)
Sponsored-by: On-Waves ehf
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index 98253ff..feda2aa 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -340,6 +340,20 @@
return CMD_SUCCESS;
}
+DEFUN(show_stats_level,
+ show_stats_level_cmd,
+ "show stats level (global|peer|subscriber)",
+ SHOW_STR SHOW_STATS_STR
+ "Show global groups only\n"
+ "Show global and network peer related groups\n"
+ "Show global, peer, and subscriber groups\n")
+{
+ int level = get_string_value(stats_class_strs, argv[0]);
+ vty_out_statistics_partial(vty, "", level);
+
+ return CMD_SUCCESS;
+}
+
static int config_write_stats_reporter(struct vty *vty, struct osmo_stats_reporter *srep)
{
if (srep == NULL)
@@ -406,6 +420,7 @@
void osmo_stats_vty_add_cmds()
{
install_element_ve(&show_stats_cmd);
+ install_element_ve(&show_stats_level_cmd);
install_element(CONFIG_NODE, &cfg_stats_reporter_statsd_cmd);
install_element(CONFIG_NODE, &cfg_no_stats_reporter_statsd_cmd);