summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-06 15:21:56 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-28 23:51:12 +0100
commit738d9e22108a8e472458fad42509fd8d96994d6c (patch)
tree6f2a984f90708d4093a1adf298b3b8dba12e80ab /src
parent9732cb4a92a883c7e9f7dcd928b6e22976a797ca (diff)
stats: Add vty_out_stat_item_group
This functions dumps a whole stat item group to the VTY. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
-rw-r--r--src/vty/utils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/vty/utils.c b/src/vty/utils.c
index d0ad431d..e190337c 100644
--- a/src/vty/utils.c
+++ b/src/vty/utils.c
@@ -29,6 +29,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/core/utils.h>
#include <osmocom/vty/vty.h>
@@ -63,6 +64,27 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix,
};
}
+/*! \brief print a stat item group to given VTY
+ * \param[in] vty The VTY to which it should be printed
+ * \param[in] prefix Any additional log prefix ahead of each line
+ * \param[in] statg Stat item group to be printed
+ */
+void vty_out_stat_item_group(struct vty *vty, const char *prefix,
+ struct stat_item_group *statg)
+{
+ unsigned int i;
+
+ vty_out(vty, "%s%s:%s", prefix, statg->desc->group_description,
+ VTY_NEWLINE);
+ for (i = 0; i < statg->desc->num_items; i++) {
+ struct stat_item *item = statg->items[i];
+ vty_out(vty, " %s%s: %8" PRIi32 " %s%s",
+ prefix, item->desc->description,
+ stat_item_get_last(item),
+ item->desc->unit, VTY_NEWLINE);
+ };
+}
+
/*! \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,