[asterisk-commits] res config pgsql: Add message on cli failed command status (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 9 13:45:33 CST 2016
Joshua Colp has submitted this change and it was merged.
Change subject: res_config_pgsql: Add message on cli failed command status
......................................................................
res_config_pgsql: Add message on cli failed command status
In case failed of command "realtime show pgsql status" show a message the data
of connection to more clear information in error.
Change-Id: Ia8e9e2400466606e7118f52a46e05df0719b6a29
---
M res/res_config_pgsql.c
1 file changed, 19 insertions(+), 18 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
George Joseph: Looks good to me, but someone else must approve
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 7fe1daa..d0e01bc 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999-2010, Digium, Inc.
+ * Copyright (C) 1999 - 2016, Digium, Inc.
*
* Manuel Guesdon <mguesdon at oxymium.net> - PostgreSQL RealTime Driver Author/Adaptor
* Mark Spencer <markster at digium.com> - Asterisk Author
@@ -1571,7 +1571,7 @@
static char *handle_cli_realtime_pgsql_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- char status[256], credentials[100] = "";
+ char connection_info[256], credentials[100] = "";
int ctimesec = time(NULL) - connect_time;
switch (cmd) {
@@ -1588,36 +1588,37 @@
if (a->argc != 4)
return CLI_SHOWUSAGE;
+ if (!ast_strlen_zero(dbhost))
+ snprintf(connection_info, sizeof(connection_info), "%s@%s, port %d", dbname, dbhost, dbport);
+ else if (!ast_strlen_zero(dbsock))
+ snprintf(connection_info, sizeof(connection_info), "%s on socket file %s", dbname, dbsock);
+ else
+ snprintf(connection_info, sizeof(connection_info), "%s@%s", dbname, dbhost);
+
+ if (!ast_strlen_zero(dbuser))
+ snprintf(credentials, sizeof(credentials), " with username %s", dbuser);
+
if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
- if (!ast_strlen_zero(dbhost))
- snprintf(status, sizeof(status), "Connected to %s@%s, port %d", dbname, dbhost, dbport);
- else if (!ast_strlen_zero(dbsock))
- snprintf(status, sizeof(status), "Connected to %s on socket file %s", dbname, dbsock);
- else
- snprintf(status, sizeof(status), "Connected to %s@%s", dbname, dbhost);
-
- if (!ast_strlen_zero(dbuser))
- snprintf(credentials, sizeof(credentials), " with username %s", dbuser);
-
if (ctimesec > 31536000)
- ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
- status, credentials, ctimesec / 31536000, (ctimesec % 31536000) / 86400,
+ ast_cli(a->fd, "Connected to %s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
+ connection_info, credentials, ctimesec / 31536000, (ctimesec % 31536000) / 86400,
(ctimesec % 86400) / 3600, (ctimesec % 3600) / 60, ctimesec % 60);
else if (ctimesec > 86400)
- ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status,
+ ast_cli(a->fd, "Connected to %s%s for %d days, %d hours, %d minutes, %d seconds.\n", connection_info,
credentials, ctimesec / 86400, (ctimesec % 86400) / 3600, (ctimesec % 3600) / 60,
ctimesec % 60);
else if (ctimesec > 3600)
- ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, credentials,
+ ast_cli(a->fd, "Connected to %s%s for %d hours, %d minutes, %d seconds.\n", connection_info, credentials,
ctimesec / 3600, (ctimesec % 3600) / 60, ctimesec % 60);
else if (ctimesec > 60)
- ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, ctimesec / 60,
+ ast_cli(a->fd, "Connected to %s%s for %d minutes, %d seconds.\n", connection_info, credentials, ctimesec / 60,
ctimesec % 60);
else
- ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctimesec);
+ ast_cli(a->fd, "Connected to %s%s for %d seconds.\n", connection_info, credentials, ctimesec);
return CLI_SUCCESS;
} else {
+ ast_cli(a->fd, "Unable to connect %s%s\n", connection_info, credentials);
return CLI_FAILURE;
}
}
--
To view, visit https://gerrit.asterisk.org/2219
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia8e9e2400466606e7118f52a46e05df0719b6a29
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list