Change in osmo-mgw[master]: Add vty command 'show mgcp active'

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

keith gerrit-no-reply at lists.osmocom.org
Fri May 7 19:04:34 UTC 2021


keith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24131 )

Change subject: Add vty command 'show mgcp active'
......................................................................

Add vty command 'show mgcp active'

With just one E1 line, the 'show mgcp' command outputs
several hundred lines to the vty. Add a 'active' parameter to
only show endpoints that are active.

Change-Id: I23a26b4fdc03d8b2469d293dd6c06ed83ce739e9
---
M src/libosmo-mgcp/mgcp_vty.c
1 file changed, 38 insertions(+), 14 deletions(-)

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



diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 521f86e..5892df1 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -301,9 +301,10 @@
 }
 
 
-static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats)
+static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats, int active_only)
 {
 	int i;
+	int active_count = 0;
 
 	vty_out(vty, "%s trunk %d with %d endpoints:%s",
 		trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1",
@@ -316,29 +317,30 @@
 
 	for (i = 0; i < trunk->number_endpoints; ++i) {
 		struct mgcp_endpoint *endp = trunk->endpoints[i];
-		dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
-			      show_stats);
-		if (i < trunk->number_endpoints - 1)
-			vty_out(vty, "%s", VTY_NEWLINE);
+		if (!active_only || !llist_empty(&endp->conns)) {
+			dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
+				      show_stats);
+			if (i < trunk->number_endpoints - 1)
+				vty_out(vty, "%s", VTY_NEWLINE);
+		}
+		if (!llist_empty(&endp->conns))
+			active_count++;
 	}
 
+	if (active_count == 0)
+		vty_out(vty, "No endpoints in use.%s", VTY_NEWLINE);
+
 	if (show_stats)
 		dump_ratectr_trunk(vty, trunk);
 }
 
-#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
-
-DEFUN(show_mcgp, show_mgcp_cmd,
-      "show mgcp [stats]",
-      SHOW_STR
-      SHOW_MGCP_STR
-      "Include Statistics\n")
+static int mgcp_show(struct vty *vty, int argc, const char **argv,
+		     int show_stats, int active_only)
 {
 	struct mgcp_trunk *trunk;
-	int show_stats = argc >= 1;
 
 	llist_for_each_entry(trunk, &g_cfg->trunks, entry)
-		dump_trunk(vty, trunk, show_stats);
+		dump_trunk(vty, trunk, show_stats, active_only);
 
 	if (g_cfg->osmux)
 		vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
@@ -350,6 +352,27 @@
 	return CMD_SUCCESS;
 }
 
+#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
+
+DEFUN(show_mgcp, show_mgcp_cmd,
+      "show mgcp [stats]",
+      SHOW_STR
+      SHOW_MGCP_STR
+      "Include statistics\n")
+{
+	int show_stats = argc >= 1;
+	return mgcp_show(vty, argc, argv, show_stats, 0);
+}
+
+DEFUN(show_mgcp_active, show_mgcp_active_cmd,
+      "show mgcp active",
+      SHOW_STR
+      SHOW_MGCP_STR
+      "Show only endpoints with active connections\n")
+{
+	return mgcp_show(vty, argc, argv, 0, 1);
+}
+
 static void
 dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
 {
@@ -1606,6 +1629,7 @@
 int mgcp_vty_init(void)
 {
 	install_element_ve(&show_mgcp_cmd);
+	install_element_ve(&show_mgcp_active_cmd);
 	install_element_ve(&show_mgcp_endpoint_cmd);
 	install_element_ve(&show_mgcp_trunk_endpoint_cmd);
 	install_element(ENABLE_NODE, &loop_conn_cmd);

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I23a26b4fdc03d8b2469d293dd6c06ed83ce739e9
Gerrit-Change-Number: 24131
Gerrit-PatchSet: 4
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: keith <keith at rhizomatica.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
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/20210507/3492ac0b/attachment.htm>


More information about the gerrit-log mailing list