fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/27409 )
Change subject: VTY: avoid printing duplicate rate_ctr/stat_item groups
......................................................................
VTY: avoid printing duplicate rate_ctr/stat_item groups
There can be more than one rate_ctr/stat_item groups of the same
class, registered with different index. For example, we may have
several BTS instances in osmo-bsc, and each instance would have
its own rate counter group with the matching index.
Command 'show asciidoc counters' relies on rate_ctr_for_each_group()
and osmo_stat_item_for_each_group(). These functions do iterate
over all registered rate_ctr/stat_item groups, including the ones
belonging to the same class but having different indexes. This is
why there can be duplicates in the output of this command.
A more sophisticated approach would be adding new for_each functions
ensuring that the given rate_ctr_group_handler_t is called only once
for groups of the same class. However, as a quick workaround we can
assume that there is always a group with index == 0, and avoid
printing groups with index != 0.
Change-Id: I1e66bc5720dfe255b480780aa9a0b76f4c0cc1fe
Fixes: OS#4848
---
M src/vty/stats_vty.c
1 file changed, 8 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/09/27409/1
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index a73fafb..299b341 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -500,6 +500,10 @@
{
struct vty *vty = sctx_;
+ /* Avoid printing duplicate groups */
+ if (ctrg->idx != 0)
+ return 0;
+
char *group_description = osmo_asciidoc_escape(ctrg->desc->group_description);
char *group_name_prefix = osmo_asciidoc_escape(ctrg->desc->group_name_prefix);
@@ -550,6 +554,10 @@
char *group_name_prefix = osmo_asciidoc_escape(statg->desc->group_name_prefix);
char *group_description = osmo_asciidoc_escape(statg->desc->group_description);
+ /* Avoid printing duplicate groups */
+ if (statg->idx != 0)
+ return 0;
+
struct vty *vty = sctx_;
vty_out(vty, "%s%s", group_description ? group_description : "" ,
VTY_NEWLINE);
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/27409
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I1e66bc5720dfe255b480780aa9a0b76f4c0cc1fe
Gerrit-Change-Number: 27409
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange