[MERGED] libosmocore[master]: Ctrl: add rate counter group introspection

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Nov 24 10:44:28 UTC 2017


Max has submitted this change and it was merged.

Change subject: Ctrl: add rate counter group introspection
......................................................................


Ctrl: add rate counter group introspection

Before user have to know group name and index in advance to request rate
counter value. Introduce introspection function which allows user to
obtain all the groups and their indexes by requesting 'rate_ctr.*'
variable.

This simplifies KPI dumping over ctrl interface.

Change-Id: Ifad8b4f0360c8bcd123a838676516476e84c246a
Related: OS#2550
---
M src/ctrl/control_if.c
1 file changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 07b17c9..665239a 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -534,6 +534,19 @@
 	return CTRL_CMD_ERROR;
 }
 
+static int ctrl_rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *data)
+{
+	struct ctrl_cmd *cmd = data;
+
+	cmd->reply = talloc_asprintf_append(cmd->reply, "%s.%u;", ctrg->desc->group_name_prefix, ctrg->idx);
+	if (!cmd->reply) {
+		cmd->reply = "OOM";
+		return -1;
+	}
+
+	return 0;
+}
+
 /* rate_ctr */
 CTRL_CMD_DEFINE(rate_ctr, "rate_ctr *");
 static int get_rate_ctr(struct ctrl_cmd *cmd, void *data)
@@ -574,6 +587,11 @@
 		intv = RATE_CTR_INTV_HOUR;
 	} else if (!strcmp(interval, "per_day")) {
 		intv = RATE_CTR_INTV_DAY;
+	} else if (!strcmp(interval, "*")) {
+		intv = rate_ctr_for_each_group(ctrl_rate_ctr_group_handler, cmd);
+		if (intv < 0)
+			return CTRL_CMD_ERROR;
+		return CTRL_CMD_REPLY;
 	} else {
 		talloc_free(dup);
 		cmd->reply = "Wrong interval.";

-- 
To view, visit https://gerrit.osmocom.org/5017
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifad8b4f0360c8bcd123a838676516476e84c246a
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list