Change in osmo-bsc[master]: stats: add BTS uptime counter

iedemam gerrit-no-reply at lists.osmocom.org
Thu Mar 4 13:14:26 UTC 2021


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


Change subject: stats: add BTS uptime counter
......................................................................

stats: add BTS uptime counter

Change-Id: Ib17674bbe95e828cebff12de9e0b30f06447ef6c
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bsc_init.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/bts_ipaccess_nanobts.c
5 files changed, 33 insertions(+), 0 deletions(-)



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

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index 6b58c7e..dae5eff 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -17,6 +17,7 @@
 #include "osmocom/bsc/bts_sm.h"
 
 enum bts_counter_id {
+	BTS_CTR_UPTIME_SEC,
 	BTS_CTR_CHREQ_TOTAL,
 	BTS_CTR_CHREQ_ATTEMPTED_EMERG,
 	BTS_CTR_CHREQ_ATTEMPTED_CALL,
@@ -670,3 +671,6 @@
 
 enum gsm_bts_type_variant str2btsvariant(const char *arg);
 const char *btsvariant2str(enum gsm_bts_type_variant v);
+
+#define BTS_UPTIME_SAMPLE_INTERVAL 1 /* in seconds */
+void bts_update_uptime(struct gsm_bts *bts);
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index af1c8e8..c2de815 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -1209,6 +1209,9 @@
 	/* Timer for periodic channel load measurements to maintain each BTS's T3122. */
 	struct osmo_timer_list t3122_chan_load_timer;
 
+	/* Timer to update each BTS's uptime counter. */
+	struct osmo_timer_list bts_uptime_timer;
+
 	struct {
 		struct mgcp_client_conf *conf;
 		struct mgcp_client *client;
diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c
index b959c9f..0012129 100644
--- a/src/osmo-bsc/bsc_init.c
+++ b/src/osmo-bsc/bsc_init.c
@@ -85,6 +85,18 @@
 	osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0);
 }
 
+static void update_bts_uptime_timer(void *data)
+{
+	struct gsm_network *net = data;
+	struct gsm_bts *bts;
+
+	llist_for_each_entry(bts, &net->bts_list, list)
+		bts_update_uptime(bts);
+
+	/* Keep this timer ticking. */
+	osmo_timer_schedule(&net->bts_uptime_timer, BTS_UPTIME_SAMPLE_INTERVAL, 0);
+}
+
 static struct gsm_network *bsc_network_init(void *ctx)
 {
 	struct gsm_network *net = gsm_network_init(ctx);
@@ -129,6 +141,10 @@
 	osmo_timer_setup(&net->t3122_chan_load_timer, update_t3122_chan_load_timer, net);
 	osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0);
 
+	/* init uptime tracking timer */
+	osmo_timer_setup(&net->bts_uptime_timer, update_bts_uptime_timer, net);
+	osmo_timer_schedule(&net->bts_uptime_timer, BTS_UPTIME_SAMPLE_INTERVAL, 0);
+
 	net->cbc->net = net;
 	net->cbc->mode = BSC_CBC_LINK_MODE_DISABLED;
 	net->cbc->server.local_addr = bsc_cbc_default_server_local_addr;
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 1d0979d..5be4d79 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -762,6 +762,9 @@
 }
 
 const struct rate_ctr_desc bts_ctr_description[] = {
+	[BTS_CTR_UPTIME_SEC] = \
+		{ "uptime:sec",
+		  "Uptime in seconds" },
 	[BTS_CTR_CHREQ_TOTAL] = \
 		{ "chreq:total",
 		  "Received channel requests" },
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c
index 16fa201..5b0e7e4 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -64,6 +64,13 @@
 	return "disconnected";
 }
 
+void bts_update_uptime(struct gsm_bts *bts)
+{
+	if (bts->oml_link && all_trx_rsl_connected_unlocked(bts)) {
+		rate_ctr_add(&bts->bts_ctrs->ctr[BTS_CTR_UPTIME_SEC], BTS_UPTIME_SAMPLE_INTERVAL);
+	}
+}
+
 struct gsm_bts_model bts_model_nanobts = {
 	.type = GSM_BTS_TYPE_NANOBTS,
 	.name = "nanobts",

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ib17674bbe95e828cebff12de9e0b30f06447ef6c
Gerrit-Change-Number: 23234
Gerrit-PatchSet: 1
Gerrit-Owner: iedemam <michael at kapsulate.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210304/2a6d9540/attachment.htm>


More information about the gerrit-log mailing list