pespin has uploaded this change for review.

View Change

Introduce stats msc.ran_peers.{total,active}

osmo_stats_init() was already being called despite no stats were being
used.

Change-Id: Ib01576036f34ac7f21c5bce0155b50932eb9b72a
---
M include/osmocom/smlc/smlc_data.h
M src/osmo-smlc/lb_peer.c
M src/osmo-smlc/smlc_data.c
M src/osmo-smlc/smlc_vty.c
4 files changed, 55 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-smlc refs/changes/79/40679/1
diff --git a/include/osmocom/smlc/smlc_data.h b/include/osmocom/smlc/smlc_data.h
index dc77507..2e17dd0 100644
--- a/include/osmocom/smlc/smlc_data.h
+++ b/include/osmocom/smlc/smlc_data.h
@@ -37,6 +37,7 @@
_LAST_CTRL_NODE_SMLC
};

+/* rate_ctr */
enum {
SMLC_CTR_BSSMAP_LE_RX_UDT_RESET,
SMLC_CTR_BSSMAP_LE_RX_UDT_RESET_ACK,
@@ -58,3 +59,9 @@
SMLC_CTR_BSSMAP_LE_TX_DT1_PERFORM_LOCATION_RESPONSE,
SMLC_CTR_BSSMAP_LE_TX_DT1_BSSLAP_TA_REQUEST,
};
+
+/* osmo_stat */
+enum {
+ SMLC_STAT_LB_PEERS_TOTAL,
+ SMLC_STAT_LB_PEERS_ACTIVE,
+};
diff --git a/src/osmo-smlc/lb_peer.c b/src/osmo-smlc/lb_peer.c
index ce323c4..3f4c23e 100644
--- a/src/osmo-smlc/lb_peer.c
+++ b/src/osmo-smlc/lb_peer.c
@@ -23,6 +23,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/fsm.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/bssmap_le.h>
#include <osmocom/sigtran/sccp_helpers.h>

@@ -57,6 +58,7 @@
fi->priv = lbp;

llist_add(&lbp->entry, &sli->lb_peers);
+ osmo_stat_item_inc(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_TOTAL), 1);

return lbp;
}
@@ -294,6 +296,12 @@
}
}

+static void lb_peer_st_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ if (prev_state != LB_PEER_ST_READY)
+ osmo_stat_item_inc(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
+}
+
static void lb_peer_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lb_peer *lbp = fi->priv;
@@ -368,6 +376,12 @@
}
}

+static void lb_peer_st_ready_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
+{
+ if (next_state != LB_PEER_ST_READY)
+ osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
+}
+
static int lb_peer_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
struct lb_peer *lbp = fi->priv;
@@ -375,10 +389,17 @@
return 0;
}

+/* struct lb_peer destructor: */
static void lb_peer_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
{
struct lb_peer *lbp = fi->priv;
+
lb_peer_discard_all_conns(lbp);
+
+ if (lbp->fi->state == LB_PEER_ST_READY)
+ osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
+ osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_TOTAL), 1);
+
llist_del(&lbp->entry);
}

@@ -437,6 +458,8 @@
[LB_PEER_ST_READY] = {
.name = "READY",
.action = lb_peer_st_ready,
+ .onenter = lb_peer_st_ready_onenter,
+ .onleave = lb_peer_st_ready_onleave,
.in_event_mask = 0
| S(LB_PEER_EV_RX_RESET)
| S(LB_PEER_EV_MSG_UP_CO_INITIAL)
diff --git a/src/osmo-smlc/smlc_data.c b/src/osmo-smlc/smlc_data.c
index d51bceb..10609a5 100644
--- a/src/osmo-smlc/smlc_data.c
+++ b/src/osmo-smlc/smlc_data.c
@@ -54,6 +54,19 @@
smlc_ctr_description,
};

+static const struct osmo_stat_item_desc smlc_stat_item_description[] = {
+ [SMLC_STAT_LB_PEERS_TOTAL] = { "smlc.lb_peers.total", "Total Lb peers seen since startup", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
+ [SMLC_STAT_LB_PEERS_ACTIVE] = { "smlc.lb_peers.active", "Currently active Lb peers", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
+};
+
+static const struct osmo_stat_item_group_desc smlc_statg_desc = {
+ "smlc",
+ "serving mobile location center",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(smlc_stat_item_description),
+ smlc_stat_item_description,
+};
+
struct smlc_state *smlc_state_alloc(void *ctx)
{
struct smlc_state *smlc = talloc_zero(ctx, struct smlc_state);
@@ -61,5 +74,14 @@
INIT_LLIST_HEAD(&smlc->subscribers);
INIT_LLIST_HEAD(&smlc->cell_locations);
smlc->ctrs = rate_ctr_group_alloc(smlc, &smlc_ctrg_desc, 0);
+
+ smlc->statg = osmo_stat_item_group_alloc(smlc, &smlc_statg_desc, 0);
+ if (!smlc->statg)
+ goto ret_free;
return smlc;
+
+ret_free:
+ rate_ctr_group_free(smlc->ctrs);
+ talloc_free(smlc);
+ return NULL;
}
diff --git a/src/osmo-smlc/smlc_vty.c b/src/osmo-smlc/smlc_vty.c
index 36ca47e..c6ae83a 100644
--- a/src/osmo-smlc/smlc_vty.c
+++ b/src/osmo-smlc/smlc_vty.c
@@ -23,6 +23,8 @@
#include <osmocom/ctrl/control_vty.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/misc.h>
+#include <osmocom/vty/stats.h>
+#include <osmocom/vty/vty.h>

#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/sccp_sap.h>
@@ -37,6 +39,7 @@
osmo_talloc_vty_add_cmds();
ctrl_vty_init(vty_app_info->tall_ctx);
osmo_fsm_vty_add_cmds();
+ osmo_stats_vty_add_cmds();

osmo_ss7_vty_init_asp(vty_app_info->tall_ctx);
osmo_sccp_vty_init();

To view, visit change 40679. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-smlc
Gerrit-Branch: master
Gerrit-Change-Id: Ib01576036f34ac7f21c5bce0155b50932eb9b72a
Gerrit-Change-Number: 40679
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>