Change in libosmocore[master]: ns2: nse: add a uptime/downtime to track the last state change

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
Sun Sep 5 21:24:31 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/25349 )


Change subject: ns2: nse: add a uptime/downtime to track the last state change
......................................................................

ns2: nse: add a uptime/downtime to track the last state change

To show adminstrator the last state change of a nse add a timestamp and
show it on the vty

> show ns nse 1234

NSEI 01234: UDP, ALIVE since 0d 0h 0m 16s
 FSM Instance Name: 'GPRS-NS2-SNS-SGSN(NSE01234-SNS)[0x6120000012a0]', ID: 'NSE01234-SNS'
  Log-Level: 'DEBUG', State: 'CONFIGURED'
  Timer: 4
 Maximum number of remote  NS-VCs: 8, IPv4 Endpoints: 2, IPv6 Endpoints: 0
 [...]

Change-Id: I8143080a3c5c9a55d37dfad44ba2ac6561daa216
---
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_vty.c
3 files changed, 10 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/49/25349/1

diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 6c48ca6..c00537d 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -838,6 +838,7 @@
 	nse->mtu = 0;
 	llist_add_tail(&nse->list, &nsi->nse);
 	INIT_LLIST_HEAD(&nse->nsvc);
+	osmo_clock_gettime(CLOCK_MONOTONIC, &nse->ts_alive_change);
 
 	return nse;
 }
@@ -1400,6 +1401,7 @@
 	/* wait until both data_weight and sig_weight are != 0 before declaring NSE as alive */
 	if (unblocked && nse->sum_data_weight && nse->sum_sig_weight) {
 		nse->alive = true;
+		osmo_clock_gettime(CLOCK_MONOTONIC, &nse->ts_alive_change);
 		ns2_prim_status_ind(nse, NULL, 0, GPRS_NS2_AFF_CAUSE_RECOVERY);
 		nse->first = false;
 		return;
@@ -1408,6 +1410,7 @@
 	if (nse->alive && (nse->sum_data_weight == 0 || nse->sum_sig_weight == 0)) {
 		/* nse became unavailable */
 		nse->alive = false;
+		osmo_clock_gettime(CLOCK_MONOTONIC, &nse->ts_alive_change);
 		ns2_prim_status_ind(nse, NULL, 0, GPRS_NS2_AFF_CAUSE_FAILURE);
 	}
 }
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index afe6b69..cd9969c 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -220,6 +220,9 @@
 
 	/*! recursive anchor */
 	bool freed;
+
+	/*! when the NSE became alive or dead */
+	struct timespec ts_alive_change;
 };
 
 /*! Structure representing a single NS-VC */
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 52ce207..86471b8 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1900,8 +1900,10 @@
 	if (persistent_only && !nse->persistent)
 		return;
 
-	vty_out(vty, "NSEI %05u: %s, %s%s", nse->nsei, gprs_ns2_lltype_str(nse->ll),
-		nse->alive ? "ALIVE" : "DEAD", VTY_NEWLINE);
+	vty_out(vty, "NSEI %05u: %s, %s since ", nse->nsei, gprs_ns2_lltype_str(nse->ll),
+		nse->alive ? "ALIVE" : "DEAD");
+	vty_out_uptime(vty, &nse->ts_alive_change);
+	vty_out_newline(vty);
 
 	ns2_sns_dump_vty(vty, " ", nse, stats);
 	llist_for_each_entry(nsvc, &nse->nsvc, list) {

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8143080a3c5c9a55d37dfad44ba2ac6561daa216
Gerrit-Change-Number: 25349
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210905/b3ab4f51/attachment.htm>


More information about the gerrit-log mailing list