Change in libosmocore[master]: ns2: nsvc: 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/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Sep 23 13:06:25 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/25350 )

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

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

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

> show ns nsei 1234
NSEI 01234: UDP, DEAD since 0d 0h 1m 42s
[...]
  4 NS-VC:
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22000<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22000<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=2 data_weight=2 udp)[127.0.0.1]:22001<>[127.0.0.1]:23000 ALIVE since 0d 0h 0m 1s
   UNBLOCKED DYNAMIC sig_weight=1 data_weight=1 udp)[127.0.0.1]:22001<>[127.0.0.1]:23001 ALIVE since 0d 0h 0m 1s

Related: OS#5028
Change-Id: Ie3a039a209869295afa5feda39297cee81fedf22
---
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_vc_fsm.c
M src/gb/gprs_ns2_vty.c
M tests/gb/gprs_ns2_vty.vty
5 files changed, 24 insertions(+), 13 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index c00537d..6bccf65 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -621,6 +621,7 @@
 
 	llist_add_tail(&nsvc->list, &nse->nsvc);
 	llist_add_tail(&nsvc->blist, &bind->nsvc);
+	osmo_clock_gettime(CLOCK_MONOTONIC, &nsvc->ts_alive_change);
 	ns2_nse_update_mtu(nse);
 
 	return nsvc;
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index cd9969c..bfb12d9 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -270,6 +270,9 @@
 
 	/*! recursive anchor */
 	bool freed;
+
+	/*! when the NSVC became alive or dead */
+	struct timespec ts_alive_change;
 };
 
 /*! Structure repesenting a bind instance. E.g. IPv4 listen port. */
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 03a355b..fa8cec2 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -414,8 +414,10 @@
 	struct gprs_ns2_vc *nsvc = priv->nsvc;
 	struct gprs_ns2_nse *nse = nsvc->nse;
 
-	if (old_state != GPRS_NS2_ST_UNBLOCKED)
+	if (old_state != GPRS_NS2_ST_UNBLOCKED) {
 		RATE_CTR_INC_NS(nsvc, NS_CTR_UNBLOCKED);
+		osmo_clock_gettime(CLOCK_MONOTONIC, &nsvc->ts_alive_change);
+	}
 
 	priv->accept_unitdata = true;
 	ns2_nse_notify_unblocked(nsvc, true);
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 86471b8..41f581e 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1875,16 +1875,21 @@
 void ns2_vty_dump_nsvc(struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats)
 {
 	if (nsvc->nsvci_is_valid)
-		vty_out(vty, "   NSVCI %05u: %s %s %s%s", nsvc->nsvci,
+		vty_out(vty, "   NSVCI %05u: %s %s %s %s since ", nsvc->nsvci,
 			osmo_fsm_inst_state_name(nsvc->fi),
 			nsvc->persistent ? "PERSIST" : "DYNAMIC",
-			gprs_ns2_ll_str(nsvc), VTY_NEWLINE);
+			gprs_ns2_ll_str(nsvc),
+			ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD");
 	else
-		vty_out(vty, "   %s %s sig_weight=%u data_weight=%u %s%s",
+		vty_out(vty, "   %s %s sig_weight=%u data_weight=%u %s %s since ",
 			osmo_fsm_inst_state_name(nsvc->fi),
 			nsvc->persistent ? "PERSIST" : "DYNAMIC",
 			nsvc->sig_weight, nsvc->data_weight,
-			gprs_ns2_ll_str(nsvc), VTY_NEWLINE);
+			gprs_ns2_ll_str(nsvc),
+			ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD");
+
+	vty_out_uptime(vty, &nsvc->ts_alive_change);
+	vty_out_newline(vty);
 
 	if (stats) {
 		vty_out_rate_ctr_group(vty, "    ", nsvc->ctrg);
diff --git a/tests/gb/gprs_ns2_vty.vty b/tests/gb/gprs_ns2_vty.vty
index 35bee1e..4be10d5 100644
--- a/tests/gb/gprs_ns2_vty.vty
+++ b/tests/gb/gprs_ns2_vty.vty
@@ -40,11 +40,11 @@
 OsmoNSdummy# show ns
 NSEI 01234: UDP, DEAD since 0d 0h 0m 0s
   1 NS-VC:
-   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
+   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s
 UDP bind: 127.0.0.14:42999 DSCP: 0 Priority: 0
   IP-SNS signalling weight: 1 data weight: 1
   1 NS-VC:
-   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
+   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s
 OsmoNSdummy# configure terminal
 OsmoNSdummy(config)# ns
 OsmoNSdummy(config-ns)# nse 1234
@@ -54,15 +54,15 @@
 OsmoNSdummy# show ns
 NSEI 01234: UDP, DEAD since 0d 0h 0m 0s
   3 NS-VC:
-   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
-   RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496
-   RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496
+   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s
+   RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD since 0d 0h 0m 0s
+   RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD since 0d 0h 0m 0s
 UDP bind: 127.0.0.14:42999 DSCP: 0 Priority: 0
   IP-SNS signalling weight: 1 data weight: 1
   3 NS-VC:
-   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496
-   RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496
-   RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496
+   RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s
+   RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD since 0d 0h 0m 0s
+   RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD since 0d 0h 0m 0s
 OsmoNSdummy# configure terminal
 OsmoNSdummy(config)# ns
 OsmoNSdummy(config-ns)# nse 1234

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie3a039a209869295afa5feda39297cee81fedf22
Gerrit-Change-Number: 25350
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210923/86e9dd68/attachment.htm>


More information about the gerrit-log mailing list