summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/vty/misc.h2
-rw-r--r--src/vty/utils.c58
2 files changed, 60 insertions, 0 deletions
diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h
index ad878db2..99c2ee68 100644
--- a/include/osmocom/vty/misc.h
+++ b/include/osmocom/vty/misc.h
@@ -16,5 +16,7 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix,
void vty_out_stat_item_group(struct vty *vty, const char *prefix,
struct stat_item_group *statg);
+void vty_out_statistics_full(struct vty *vty, const char *prefix);
+
int osmo_vty_write_config_file(const char *filename);
int osmo_vty_save_config_file(void);
diff --git a/src/vty/utils.c b/src/vty/utils.c
index 93e9ef48..474a25ef 100644
--- a/src/vty/utils.c
+++ b/src/vty/utils.c
@@ -31,6 +31,7 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/statistics.h>
#include <osmocom/vty/vty.h>
@@ -108,6 +109,63 @@ void vty_out_stat_item_group(struct vty *vty, const char *prefix,
stat_item_for_each_item(statg, stat_item_handler, &vctx);
}
+static int stat_item_group_handler(struct stat_item_group *statg, void *vctx_)
+{
+ struct vty_out_context *vctx = vctx_;
+ struct vty *vty = vctx->vty;
+
+ if (statg->idx)
+ vty_out(vty, "%s%s (%d):%s", vctx->prefix,
+ statg->desc->group_description, statg->idx,
+ VTY_NEWLINE);
+ else
+ vty_out(vty, "%s%s:%s", vctx->prefix,
+ statg->desc->group_description, VTY_NEWLINE);
+
+ stat_item_for_each_item(statg, stat_item_handler, vctx);
+
+ return 0;
+}
+
+static int rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *vctx_)
+{
+ struct vty_out_context *vctx = vctx_;
+ struct vty *vty = vctx->vty;
+
+ if (ctrg->idx)
+ vty_out(vty, "%s%s (%d):%s", vctx->prefix,
+ ctrg->desc->group_description, ctrg->idx, VTY_NEWLINE);
+ else
+ vty_out(vty, "%s%s:%s", vctx->prefix,
+ ctrg->desc->group_description, VTY_NEWLINE);
+
+ rate_ctr_for_each_counter(ctrg, rate_ctr_handler, vctx);
+
+ return 0;
+}
+
+static int handle_counter(struct osmo_counter *counter, void *vctx_)
+{
+ struct vty_out_context *vctx = vctx_;
+ struct vty *vty = vctx->vty;
+
+ vty_out(vty, " %s%s: %8lu%s",
+ vctx->prefix, counter->description,
+ osmo_counter_get(counter), VTY_NEWLINE);
+
+ return 0;
+}
+
+void vty_out_statistics_full(struct vty *vty, const char *prefix)
+{
+ struct vty_out_context vctx = {vty, prefix};
+
+ vty_out(vty, "%sUngrouped counters:%s", prefix, VTY_NEWLINE);
+ osmo_counters_for_each(handle_counter, &vctx);
+ rate_ctr_for_each_group(rate_ctr_group_handler, &vctx);
+ stat_item_for_each_group(stat_item_group_handler, &vctx);
+}
+
/*! \brief Generate a VTY command string from value_string */
char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals,
const char *prefix, const char *sep,