Change in osmo-bsc[master]: add stat_items for BTS and TRX connection stati

neels gerrit-no-reply at lists.osmocom.org
Sun Aug 29 13:53:43 UTC 2021


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/25274 )


Change subject: add stat_items for BTS and TRX connection stati
......................................................................

add stat_items for BTS and TRX connection stati

So far we have stat items per BTS. Add stat items summing overall BTS
status.

Add stat items:
- num_bts:oml_connected
- num_bts:all_trx_rsl_connected
- num_bts:total
- num_trx:rsl_connected
- num_trx:total

Related: SYS#5542
Related: Ic1b35b7406547f92818afe399a2383d154576409 (osmo-ttcn3-hacks)
Change-Id: I2057a798e681a169cc03243a09b3d6449734c010
---
M include/osmocom/bsc/bsc_stats.h
M src/osmo-bsc/bsc_stats.c
M src/osmo-bsc/bts_vty.c
M src/osmo-bsc/osmo_bsc_main.c
4 files changed, 80 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/74/25274/1

diff --git a/include/osmocom/bsc/bsc_stats.h b/include/osmocom/bsc/bsc_stats.h
index 639f87f..4250079 100644
--- a/include/osmocom/bsc/bsc_stats.h
+++ b/include/osmocom/bsc/bsc_stats.h
@@ -21,6 +21,7 @@
 #include <osmocom/core/rate_ctr.h>
 
 struct osmo_stat_item_group_desc;
+struct gsm_network;
 
 /* OsmoBSC rate_ctr indexes */
 enum {
@@ -87,7 +88,11 @@
 
 /* OsmoBSC stat_item indexes */
 enum {
+	BSC_STAT_NUM_BTS_OML_CONNECTED,
+	BSC_STAT_NUM_BTS_ALL_TRX_RSL_CONNECTED,
 	BSC_STAT_NUM_BTS_TOTAL,
+	BSC_STAT_NUM_TRX_RSL_CONNECTED,
+	BSC_STAT_NUM_TRX_TOTAL,
 	BSC_STAT_NUM_MSC_CONNECTED,
 	BSC_STAT_NUM_MSC_TOTAL,
 };
@@ -98,3 +103,5 @@
 #define BTS_STAT_IDX_UNKNOWN (UINT16_MAX + 1)
 
 extern const struct osmo_stat_item_group_desc bsc_statg_desc;
+
+void bsc_update_connection_stats(struct gsm_network *net);
diff --git a/src/osmo-bsc/bsc_stats.c b/src/osmo-bsc/bsc_stats.c
index 36d38c2..f33e6c8 100644
--- a/src/osmo-bsc/bsc_stats.c
+++ b/src/osmo-bsc/bsc_stats.c
@@ -23,6 +23,9 @@
 #include <osmocom/core/stats.h>
 #include <osmocom/core/stat_item.h>
 
+#include <osmocom/bsc/gsm_data.h>
+#include <osmocom/bsc/bts.h>
+
 const struct rate_ctr_desc bsc_ctr_description[] = {
 	[BSC_CTR_ASSIGNMENT_ATTEMPTED] =	{"assignment:attempted", "Assignment attempts"},
 	[BSC_CTR_ASSIGNMENT_COMPLETED] =	{"assignment:completed", "Assignment completed"},
@@ -110,7 +113,11 @@
 };
 
 static const struct osmo_stat_item_desc bsc_stat_desc[] = {
+	[BSC_STAT_NUM_BTS_OML_CONNECTED] = { "num_bts:oml_connected", "Number of BTS for this BSC where OML is up", "", 16, 0 },
+	[BSC_STAT_NUM_BTS_ALL_TRX_RSL_CONNECTED] = { "num_bts:all_trx_rsl_connected", "Number of BTS for this BSC where RSL is up for all TRX", "", 16, 0 },
 	[BSC_STAT_NUM_BTS_TOTAL] = { "num_bts:total", "Number of configured BTS for this BSC", "", 16, 0 },
+	[BSC_STAT_NUM_TRX_RSL_CONNECTED] = { "num_trx:rsl_connected", "Number of TRX where RSL is up, total sum across all BTS", "", 16, 0 },
+	[BSC_STAT_NUM_TRX_TOTAL] = { "num_trx:total", "Number of configured TRX, total sum across all BTS", "", 1, 0 },
 	[BSC_STAT_NUM_MSC_CONNECTED] = { "num_msc:connected", "Number of actively connected MSCs", "", 16, 0 },
 	[BSC_STAT_NUM_MSC_TOTAL] = { "num_msc:total", "Number of configured MSCs, not necessarily connected", "", 1, 0 },
 };
@@ -122,3 +129,55 @@
 	.num_items = ARRAY_SIZE(bsc_stat_desc),
 	.item_desc = bsc_stat_desc,
 };
+
+/* Count all BTS and TRX OML and RSL stati and update stat items */
+void bsc_update_connection_stats(struct gsm_network *net)
+{
+	struct gsm_bts *bts;
+	struct gsm_bts_trx *trx;
+
+	/* Nr of configured BTS and total sum of configured TRX across all BTS */
+	int num_bts = 0;
+	int num_trx_total = 0;
+	/* Nr of BTS where OML is up */
+	int bts_oml_connected = 0;
+	/* Nr of TRX across all BTS where RSL is up */
+	int trx_rsl_connected_total = 0;
+	/* Nr of BTS that have all TRX RSL up */
+	int bts_rsl_all_trx_connected = 0;
+
+	llist_for_each_entry(bts, &net->bts_list, list) {
+		bool oml_connected = false;
+		int num_trx = 0;
+		int trx_rsl_connected = 0;
+
+		llist_for_each_entry(trx, &bts->trx_list, list) {
+			/* If any one trx is usable, it means OML for this BTS is connected */
+			if (trx_is_usable(trx))
+				oml_connected = true;
+
+			/* Count nr of TRX for this BTS */
+			num_trx++;
+			if (trx->ts[0].is_rsl_ready)
+				trx_rsl_connected++;
+		}
+
+		num_trx_total += num_trx;
+		trx_rsl_connected_total += trx_rsl_connected;
+
+		num_bts++;
+		if (oml_connected)
+			bts_oml_connected++;
+		if (trx_rsl_connected == num_trx)
+			bts_rsl_all_trx_connected++;
+	}
+
+	osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_BTS_OML_CONNECTED),
+			   bts_oml_connected);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_BTS_ALL_TRX_RSL_CONNECTED),
+			   bts_rsl_all_trx_connected);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_BTS_TOTAL), num_bts);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_TRX_RSL_CONNECTED),
+			   trx_rsl_connected_total);
+	osmo_stat_item_set(osmo_stat_item_group_get_item(net->bsc_statg, BSC_STAT_NUM_TRX_TOTAL), num_trx_total);
+}
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c
index 2b7b42b..fe1add3 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -123,7 +123,6 @@
 		/* allocate a new one */
 		bts = bsc_bts_alloc_register(gsmnet, GSM_BTS_TYPE_UNKNOWN,
 					     HARDCODED_BSIC);
-		osmo_stat_item_inc(osmo_stat_item_group_get_item(gsmnet->bsc_statg, BSC_STAT_NUM_BTS_TOTAL), 1);
 	} else
 		bts = gsm_bts_num(gsmnet, bts_nr);
 
diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index b3bd365..2fe4058 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -378,6 +378,18 @@
 	}
 }
 
+struct osmo_timer_list update_connection_stats_timer;
+
+/* Periodically call bsc_update_connection_stats() to keep stat items updated.
+ * It would be nicer to trigger this only when OML or RSL state is seen to flip. I tried hard to find all code paths
+ * that should call this and failed to get accurate results; this trivial timer covers all of them. */
+static void update_connection_stats_cb(void *data)
+{
+	bsc_update_connection_stats(bsc_gsmnet);
+	osmo_timer_setup(&update_connection_stats_timer, update_connection_stats_cb, NULL);
+	osmo_timer_schedule(&update_connection_stats_timer, 1, 0);
+}
+
 /* Callback function to be called every time we receive a signal from INPUT */
 static int inp_sig_cb(unsigned int subsys, unsigned int signal,
 		      void *handler_data, void *signal_data)
@@ -1026,6 +1038,8 @@
 	signal(SIGUSR2, &signal_handler);
 	osmo_init_ignore_signals();
 
+	update_connection_stats_cb(NULL);
+
 	if (daemonize) {
 		rc = osmo_daemonize();
 		if (rc < 0) {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/25274
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I2057a798e681a169cc03243a09b3d6449734c010
Gerrit-Change-Number: 25274
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210829/7abdba9e/attachment-0001.htm>


More information about the gerrit-log mailing list