summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2014-04-14 16:07:47 +0400
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-05-06 15:40:30 +0400
commit90c95e36dc2afe4c54e1a2bb8fefa674d209f152 (patch)
treec01f0e106f5284c1dfe8166d16767ab0ad0cdc43
parent68be1aa3d637e5870cb1ea06ef47b5fb4774e063 (diff)
nitb: Add ctrl command to get network related counters
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index aecd6cf5c..f8cd2c023 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -460,6 +460,39 @@ static int get_net_smsqueue(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_smsqueue, "smsqueue");
+static int print_counter(struct osmo_counter *counter, struct ctrl_cmd *cmd)
+{
+ cmd->reply = talloc_asprintf_append(cmd->reply, "%s,%lu\n", counter->name,
+ counter->value);
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_HELPER_VERIFY_STATUS(net_counters);
+CTRL_HELPER_SET_STATUS(net_counters);
+
+static int get_net_counters(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_network *net = cmd->node;
+
+ if (!strcmp(cmd->variable,"counters")) {
+ cmd->reply = talloc_strdup(cmd, "\n");
+ osmo_counters_for_each(print_counter, cmd);
+ }
+
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+
+ return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE(net_counters, "counters");
+
/* BTS related commands below here */
static int verify_bts_band(struct ctrl_cmd *cmd, const char *value, void *data)
{
@@ -547,6 +580,7 @@ int bsc_base_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_paging);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_oml_link);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_smsqueue);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_counters);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_band);