mgcp_client: add MGW name as logging context
Usually only one MGCP client per application is present. Then the log
lines from mgcp_client.c will be distinguishable without additional
information. When the application is using a pool of MGWs, then the
various MGCP Client instances become hard to distinguish.
- Add a possibility to set a description (name) for each MGW pool
member. When no description is set, use the domain name.
- Output the pool member name on each log line in mgcp_client.c
and mgcp_client_pool.c
Change-Id: I53ff5445c8e5faffa4ef908ffb1fdb1f47ea2904
Related: SYS#5091
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 8719e3c..4bf6cd0 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -242,6 +242,9 @@
int port;
struct reset_ep *reset_ep;
+ if (conf->description)
+ vty_out(vty, "%sdescription %s%s", indent, conf->description, VTY_NEWLINE);
+
addr = conf->local_addr;
if (addr)
vty_out(vty, "%smgw local-ip %s%s", indent, addr,
@@ -366,7 +369,7 @@
}
vty->index = &pool_member->conf;
- vty->index_sub = NULL;
+ vty->index_sub = &pool_member->conf.description;
vty->node = global_mgcp_client_pool->vty_node->node;
return CMD_SUCCESS;
@@ -387,8 +390,8 @@
/* Make sure that there are no ongoing calls */
if (pool_member->refcount > 0) {
- vty_out(vty, "%% MGCP client (MGW %u) is still serving ongoing calls -- can't remove it now!%s",
- pool_member->nr, VTY_NEWLINE);
+ vty_out(vty, "%% MGCP client (MGW %s) is still serving ongoing calls -- can't remove it now!%s",
+ mgcp_client_pool_member_name(pool_member), VTY_NEWLINE);
return CMD_WARNING;
}
@@ -417,8 +420,8 @@
/* Make sure that there are no ongoing calls */
if (pool_member->refcount > 0) {
- vty_out(vty, "%% MGCP client (MGW %u) is still serving ongoing calls -- can't reconnect it now!%s",
- pool_member->nr, VTY_NEWLINE);
+ vty_out(vty, "%% MGCP client (MGW %s) is still serving ongoing calls -- can't reconnect it now!%s",
+ mgcp_client_pool_member_name(pool_member), VTY_NEWLINE);
return CMD_WARNING;
}
@@ -431,8 +434,10 @@
/* Create a new MGCP client instance with the current config */
pool_member->client = mgcp_client_init(pool_member, &pool_member->conf);
if (!pool_member->client) {
- LOGP(DLMGCP, LOGL_ERROR, "(manual) MGW %u initalization failed\n", pool_member->nr);
- vty_out(vty, "%% MGCP client initalization failed ('%s')%s", argv[0], VTY_NEWLINE);
+ LOGP(DLMGCP, LOGL_ERROR, "(manual) MGW %s initalization failed\n",
+ mgcp_client_pool_member_name(pool_member));
+ vty_out(vty, "%% MGCP client (MGW %s) initalization failed ('%s')%s",
+ mgcp_client_pool_member_name(pool_member), argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -441,11 +446,13 @@
/* Connect client */
if (mgcp_client_connect(pool_member->client)) {
- LOGP(DLMGCP, LOGL_ERROR, "(manual) MGW %u connect failed at (%s:%u)\n",
- pool_member->nr, pool_member->conf.remote_addr, pool_member->conf.remote_port);
+ LOGP(DLMGCP, LOGL_ERROR, "(manual) MGW %s connect failed at (%s:%u)\n",
+ mgcp_client_pool_member_name(pool_member), pool_member->conf.remote_addr,
+ pool_member->conf.remote_port);
talloc_free(pool_member->client);
pool_member->client = NULL;
- vty_out(vty, "%% MGCP client initalization failed ('%s')%s", argv[0], VTY_NEWLINE);
+ vty_out(vty, "%% MGCP client (MGW %s) initalization failed ('%s')%s",
+ mgcp_client_pool_member_name(pool_member), argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -500,7 +507,7 @@
}
llist_for_each_entry(pool_member, &global_mgcp_client_pool->pool, list) {
- vty_out(vty, "%% MGW %u%s", pool_member->nr, VTY_NEWLINE);
+ vty_out(vty, "%% MGW %s%s", mgcp_client_pool_member_name(pool_member), VTY_NEWLINE);
vty_out(vty, "%% mgcp-client: %s%s", pool_member->client ? "connected" : "disconnected",
VTY_NEWLINE);
vty_out(vty, "%% service: %s%s", pool_member->blocked ? "blocked" : "unblocked", VTY_NEWLINE);
@@ -538,6 +545,8 @@
install_node(pool->vty_node, config_write_pool);
vty_init_common(pool, mgw_node);
+ install_element(mgw_node, &cfg_description_cmd);
+
install_lib_element(ENABLE_NODE, &mgw_reconnect_cmd);
install_lib_element(ENABLE_NODE, &mgw_block_cmd);
install_lib_element(ENABLE_NODE, &mgw_unblock_cmd);