From 738d9e22108a8e472458fad42509fd8d96994d6c Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 6 Oct 2015 15:21:56 +0200 Subject: stats: Add vty_out_stat_item_group This functions dumps a whole stat item group to the VTY. Sponsored-by: On-Waves ehf --- include/osmocom/vty/misc.h | 6 +++++- src/vty/utils.c | 22 ++++++++++++++++++++++ tests/Makefile.am | 8 ++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h index db552e77..ad878db2 100644 --- a/include/osmocom/vty/misc.h +++ b/include/osmocom/vty/misc.h @@ -2,6 +2,7 @@ #include #include +#include #include #define VTY_DO_LOWER 1 @@ -10,7 +11,10 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, const char *end, int do_lower); void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, - struct rate_ctr_group *ctrg); + struct rate_ctr_group *ctrg); + +void vty_out_stat_item_group(struct vty *vty, const char *prefix, + struct stat_item_group *statg); 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 d0ad431d..e190337c 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -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, diff --git a/tests/Makefile.am b/tests/Makefile.am index 223535ff..6065c0d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -67,19 +67,19 @@ ussd_ussd_test_SOURCES = ussd/ussd_test.c ussd_ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c -gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la +gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c -gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) +gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL) gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c -gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) +gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL) logging_logging_test_SOURCES = logging/logging_test.c logging_logging_test_LDADD = $(top_builddir)/src/libosmocore.la fr_fr_test_SOURCES = fr/fr_test.c -fr_fr_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) +fr_fr_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL) loggingrb_loggingrb_test_SOURCES = loggingrb/loggingrb_test.c loggingrb_loggingrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/vty/libosmovty.la -- cgit v1.2.3