Change in osmo-msc[master]: replace osmo_counter with stat items

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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Sat Apr 27 21:46:00 UTC 2019


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/13802


Change subject: replace osmo_counter with stat items
......................................................................

replace osmo_counter with stat items

Change-Id: I6a20123b263f4f808153794ee8a735092deb399e
---
M include/osmocom/msc/gsm_data.h
M src/libmsc/gsm_04_08_cc.c
M src/libmsc/gsm_09_11.c
M src/libmsc/osmo_msc.c
4 files changed, 29 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/02/13802/1

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 1a0d144..7049a63 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -10,6 +10,7 @@
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/stats.h>
+#include <osmocom/core/stat_item.h>
 #include <osmocom/gsm/gsm48.h>
 #include <osmocom/crypt/auth.h>
 
@@ -101,6 +102,11 @@
 	[MSC_CTR_BSSMAP_CIPHER_MODE_COMPLETE] =	{"bssmap:cipher_mode_complete", "Number of CIPHER MODE COMPLETE messages processed by BSSMAP layer"},
 };
 
+enum {
+	MSC_STAT_ACTIVE_CALLS,
+	MSC_STAT_NC_SS,
+};
+
 static const struct rate_ctr_group_desc msc_ctrg_desc = {
 	"msc",
 	"mobile switching center",
@@ -109,6 +115,19 @@
 	msc_ctr_description,
 };
 
+static const struct osmo_stat_item_desc msc_stat_item_description[] = {
+	[MSC_STAT_ACTIVE_CALLS] = { "msc.active_calls",     "Current active calls ", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
+	[MSC_STAT_NC_SS]        = { "msc.active_nc_ss",     ""                     , OSMO_STAT_ITEM_NO_UNIT, 4, 0},
+};
+
+static const struct osmo_stat_item_group_desc msc_statg_desc = {
+    "net",
+    "network statistics",
+    OSMO_STATS_CLASS_GLOBAL,
+    ARRAY_SIZE(msc_stat_item_description),
+    msc_stat_item_description,
+};
+
 #define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
 
 struct gsm_tz {
@@ -136,8 +155,7 @@
 	int send_mm_info;
 
 	struct rate_ctr_group *msc_ctrs;
-	struct osmo_counter *active_calls;
-	struct osmo_counter *active_nc_ss;
+	struct osmo_stat_item_group *statg;
 
 	/* layer 4 */
 	char *mncc_sock_path;
diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c
index 98c2aa3..f511601 100644
--- a/src/libmsc/gsm_04_08_cc.c
+++ b/src/libmsc/gsm_04_08_cc.c
@@ -149,7 +149,7 @@
 	/* state incoming */
 	switch (new_state) {
 	case GSM_CSTATE_ACTIVE:
-		osmo_counter_inc(trans->net->active_calls);
+		osmo_stat_item_inc(trans->net->statg->items[MSC_STAT_ACTIVE_CALLS], 1);
 		rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_ACTIVE]);
 		break;
 	}
@@ -157,7 +157,7 @@
 	/* state outgoing */
 	switch (old_state) {
 	case GSM_CSTATE_ACTIVE:
-		osmo_counter_dec(trans->net->active_calls);
+		osmo_stat_item_dec(trans->net->statg->items[MSC_STAT_ACTIVE_CALLS], 1);
 		if (new_state == GSM_CSTATE_DISCONNECT_REQ ||
 				new_state == GSM_CSTATE_DISCONNECT_IND)
 			rate_ctr_inc(&msc->ctr[MSC_CTR_CALL_COMPLETE]);
diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index c133656..778d765 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -32,6 +32,7 @@
 
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/stat_item.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
 
@@ -146,7 +147,7 @@
 			ncss_session_timeout_handler, trans);
 
 		/* Count active NC SS/USSD sessions */
-		osmo_counter_inc(conn->network->active_nc_ss);
+		osmo_stat_item_inc(trans->net->statg->items[MSC_STAT_NC_SS], 1);
 
 		trans->conn = ran_conn_get(conn, RAN_CONN_USE_TRANS_NC_SS);
 		trans->dlci = OMSC_LINKID_CB(msg);
@@ -352,7 +353,7 @@
 	}
 
 	/* Count active NC SS/USSD sessions */
-	osmo_counter_inc(net->active_nc_ss);
+	osmo_stat_item_inc(trans->net->statg->items[MSC_STAT_NC_SS], 1);
 
 	/* Assign transaction ID */
 	tid = trans_assign_trans_id(trans->net, trans->vsub, GSM48_PDISC_NC_SS);
@@ -428,7 +429,7 @@
 	osmo_timer_del(&trans->ss.timer_guard);
 
 	/* One session less */
-	osmo_counter_dec(trans->net->active_nc_ss);
+	osmo_stat_item_dec(trans->net->statg->items[MSC_STAT_NC_SS], 1);
 }
 
 int gsm0911_gsup_handler(struct vlr_subscr *vsub,
diff --git a/src/libmsc/osmo_msc.c b/src/libmsc/osmo_msc.c
index 5c6f0aa..413b34c 100644
--- a/src/libmsc/osmo_msc.c
+++ b/src/libmsc/osmo_msc.c
@@ -37,6 +37,8 @@
 #include <osmocom/msc/iu_dummy.h>
 #endif
 
+#include <osmocom/core/stat_item.h>
+
 struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv)
 {
 	struct gsm_network *net;
@@ -68,8 +70,7 @@
 		talloc_free(net);
 		return NULL;
 	}
-	net->active_calls = osmo_counter_alloc("msc.active_calls");
-	net->active_nc_ss = osmo_counter_alloc("msc.active_nc_ss");
+	net->statg = osmo_stat_item_group_alloc(net, &msc_statg_desc, 0);
 
 	net->mncc_recv = mncc_recv;
 

-- 
To view, visit https://gerrit.osmocom.org/13802
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a20123b263f4f808153794ee8a735092deb399e
Gerrit-Change-Number: 13802
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190427/910dc7ed/attachment.htm>


More information about the gerrit-log mailing list