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
This commit is contained in:
parent
4f6a7ad5f8
commit
fe53edd776
|
@ -301,9 +301,10 @@ static void dump_ratectr_trunk(struct vty *vty, struct mgcp_trunk *trunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 i;
|
||||||
|
int active_count = 0;
|
||||||
|
|
||||||
vty_out(vty, "%s trunk %d with %d endpoints:%s",
|
vty_out(vty, "%s trunk %d with %d endpoints:%s",
|
||||||
trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1",
|
trunk->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1",
|
||||||
|
@ -316,29 +317,30 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats
|
||||||
|
|
||||||
for (i = 0; i < trunk->number_endpoints; ++i) {
|
for (i = 0; i < trunk->number_endpoints; ++i) {
|
||||||
struct mgcp_endpoint *endp = trunk->endpoints[i];
|
struct mgcp_endpoint *endp = trunk->endpoints[i];
|
||||||
dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
|
if (!active_only || !llist_empty(&endp->conns)) {
|
||||||
show_stats);
|
dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
|
||||||
if (i < trunk->number_endpoints - 1)
|
show_stats);
|
||||||
vty_out(vty, "%s", VTY_NEWLINE);
|
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)
|
if (show_stats)
|
||||||
dump_ratectr_trunk(vty, trunk);
|
dump_ratectr_trunk(vty, trunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
|
static int mgcp_show(struct vty *vty, int argc, const char **argv,
|
||||||
|
int show_stats, int active_only)
|
||||||
DEFUN(show_mcgp, show_mgcp_cmd,
|
|
||||||
"show mgcp [stats]",
|
|
||||||
SHOW_STR
|
|
||||||
SHOW_MGCP_STR
|
|
||||||
"Include Statistics\n")
|
|
||||||
{
|
{
|
||||||
struct mgcp_trunk *trunk;
|
struct mgcp_trunk *trunk;
|
||||||
int show_stats = argc >= 1;
|
|
||||||
|
|
||||||
llist_for_each_entry(trunk, &g_cfg->trunks, entry)
|
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)
|
if (g_cfg->osmux)
|
||||||
vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
|
vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
|
||||||
|
@ -350,6 +352,27 @@ DEFUN(show_mcgp, show_mgcp_cmd,
|
||||||
return CMD_SUCCESS;
|
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
|
static void
|
||||||
dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
|
dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
|
||||||
{
|
{
|
||||||
|
@ -1606,6 +1629,7 @@ DEFUN(cfg_mgcp_conn_timeout,
|
||||||
int mgcp_vty_init(void)
|
int mgcp_vty_init(void)
|
||||||
{
|
{
|
||||||
install_element_ve(&show_mgcp_cmd);
|
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_endpoint_cmd);
|
||||||
install_element_ve(&show_mgcp_trunk_endpoint_cmd);
|
install_element_ve(&show_mgcp_trunk_endpoint_cmd);
|
||||||
install_element(ENABLE_NODE, &loop_conn_cmd);
|
install_element(ENABLE_NODE, &loop_conn_cmd);
|
||||||
|
|
Loading…
Reference in New Issue