2 * Asterisk -- A telephony toolkit for Linux.
4 * Copyright (C) 1999-2005, Digium, Inc.
6 * Manuel Guesdon <mguesdon@oxymium.net> - Postgresql RealTime Driver Author/Adaptor
7 * Mark Spencer <markster@digium.com> - Asterisk Author
8 * Matthew Boehm <mboehm@cytelcom.com> - MySQL RealTime Driver Author
10 * res_config_pgsql.c <Postgresql plugin for RealTime configuration engine>
12 * v1.0 - (07-11-05) - Initial version based on res_config_mysql v2.0
17 * \brief Postgresql plugin for Asterisk RealTime Architecture
19 * \author Mark Spencer <markster@digium.com>
20 * \author Manuel Guesdon <mguesdon@oxymium.net> - Postgresql RealTime Driver Author/Adaptor
22 * \arg http://www.postgresql.org
26 <depend>pgsql</depend>
31 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
36 #include <libpq-fe.h> /* PostgreSQL */
38 #include "asterisk/file.h"
39 #include "asterisk/logger.h"
40 #include "asterisk/channel.h"
41 #include "asterisk/pbx.h"
42 #include "asterisk/config.h"
43 #include "asterisk/module.h"
44 #include "asterisk/lock.h"
45 #include "asterisk/options.h"
46 #include "asterisk/utils.h"
47 #include "asterisk/cli.h"
49 AST_MUTEX_DEFINE_STATIC(pgsql_lock);
51 #define RES_CONFIG_PGSQL_CONF "res_pgsql.conf"
53 PGconn *pgsqlConn = NULL;
55 #define MAX_DB_OPTION_SIZE 64
57 static char dbhost[MAX_DB_OPTION_SIZE] = "";
58 static char dbuser[MAX_DB_OPTION_SIZE] = "";
59 static char dbpass[MAX_DB_OPTION_SIZE] = "";
60 static char dbname[MAX_DB_OPTION_SIZE] = "";
61 static char dbsock[MAX_DB_OPTION_SIZE] = "";
62 static int dbport = 5432;
63 static time_t connect_time = 0;
65 static int parse_config(void);
66 static int pgsql_reconnect(const char *database);
67 static int realtime_pgsql_status(int fd, int argc, char **argv);
71 static char cli_realtime_pgsql_status_usage[] =
72 "Usage: realtime pgsql status\n"
73 " Shows connection information for the Postgresql RealTime driver\n";
75 static struct ast_cli_entry cli_realtime_pgsql_status = {
76 { "realtime", "pgsql", "status", NULL }, realtime_pgsql_status,
77 "Shows connection information for the Postgresql RealTime driver",
78 cli_realtime_pgsql_status_usage, NULL
81 static struct ast_variable *realtime_pgsql(const char *database, const char *table, va_list ap)
83 PGresult *result = NULL;
89 const char *newparam, *newval;
90 struct ast_variable *var = NULL, *prev = NULL;
93 ast_log(LOG_WARNING, "Postgresql RealTime: No table specified.\n");
97 /* Get the first parameter and first value in our list of passed paramater/value pairs */
98 newparam = va_arg(ap, const char *);
99 newval = va_arg(ap, const char *);
100 if (!newparam || !newval) {
102 "Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
110 /* Create the first part of the query using the first parameter/value pairs we just extracted
111 If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
112 op = strchr(newparam, ' ') ? "" : " =";
114 snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op,
116 while ((newparam = va_arg(ap, const char *))) {
117 newval = va_arg(ap, const char *);
118 if (!strchr(newparam, ' '))
122 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam,
127 /* We now have our complete statement; Lets connect to the server and execute it. */
128 ast_mutex_lock(&pgsql_lock);
129 if (!pgsql_reconnect(database)) {
130 ast_mutex_unlock(&pgsql_lock);
134 if (!(result = PQexec(pgsqlConn, sql))) {
136 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
137 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
138 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
139 PQerrorMessage(pgsqlConn));
140 ast_mutex_unlock(&pgsql_lock);
143 ExecStatusType result_status = PQresultStatus(result);
144 if (result_status != PGRES_COMMAND_OK
145 && result_status != PGRES_TUPLES_OK
146 && result_status != PGRES_NONFATAL_ERROR) {
148 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
149 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
150 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
151 PQresultErrorMessage(result), PQresStatus(result_status));
152 ast_mutex_unlock(&pgsql_lock);
157 ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
159 if ((num_rows = PQntuples(result)) > 0) {
162 int numFields = PQnfields(result);
163 char **fieldnames = NULL;
165 ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
167 if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
168 ast_mutex_unlock(&pgsql_lock);
172 for (i = 0; i < numFields; i++)
173 fieldnames[i] = PQfname(result, i);
174 for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
175 for (i = 0; i < numFields; i++) {
176 stringp = PQgetvalue(result, rowIndex, i);
178 chunk = strsep(&stringp, ";");
179 if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
181 prev->next = ast_variable_new(fieldnames[i], chunk);
186 prev = var = ast_variable_new(fieldnames[i], chunk);
195 "Postgresql RealTime: Could not find any rows in table %s.\n", table);
198 ast_mutex_unlock(&pgsql_lock);
204 static struct ast_config *realtime_multi_pgsql(const char *database, const char *table, va_list ap)
206 PGresult *result = NULL;
209 const char *initfield = NULL;
213 const char *newparam, *newval;
214 struct ast_realloca ra;
215 struct ast_variable *var = NULL;
216 struct ast_config *cfg = NULL;
217 struct ast_category *cat = NULL;
220 ast_log(LOG_WARNING, "Postgresql RealTime: No table specified.\n");
224 memset(&ra, 0, sizeof(ra));
226 if (!(cfg = ast_config_new()))
229 /* Get the first parameter and first value in our list of passed paramater/value pairs */
230 newparam = va_arg(ap, const char *);
231 newval = va_arg(ap, const char *);
232 if (!newparam || !newval) {
234 "Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
242 initfield = ast_strdupa(newparam);
243 if ((op = strchr(initfield, ' '))) {
247 /* Create the first part of the query using the first parameter/value pairs we just extracted
248 If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
250 if (!strchr(newparam, ' '))
255 snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op,
257 while ((newparam = va_arg(ap, const char *))) {
258 newval = va_arg(ap, const char *);
259 if (!strchr(newparam, ' '))
263 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam,
268 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);
273 /* We now have our complete statement; Lets connect to the server and execute it. */
274 ast_mutex_lock(&pgsql_lock);
275 if (!pgsql_reconnect(database)) {
276 ast_mutex_unlock(&pgsql_lock);
280 if (!(result = PQexec(pgsqlConn, sql))) {
282 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
283 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
284 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
285 PQerrorMessage(pgsqlConn));
286 ast_mutex_unlock(&pgsql_lock);
289 ExecStatusType result_status = PQresultStatus(result);
290 if (result_status != PGRES_COMMAND_OK
291 && result_status != PGRES_TUPLES_OK
292 && result_status != PGRES_NONFATAL_ERROR) {
294 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
295 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
296 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
297 PQresultErrorMessage(result), PQresStatus(result_status));
298 ast_mutex_unlock(&pgsql_lock);
303 ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
305 if ((num_rows = PQntuples(result)) > 0) {
306 int numFields = PQnfields(result);
309 char **fieldnames = NULL;
311 ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
313 if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
314 ast_mutex_unlock(&pgsql_lock);
318 for (i = 0; i < numFields; i++)
319 fieldnames[i] = PQfname(result, i);
321 for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
323 if (!(cat = ast_category_new("")))
325 for (i = 0; i < numFields; i++) {
326 stringp = PQgetvalue(result, rowIndex, i);
328 chunk = strsep(&stringp, ";");
329 if (chunk && !ast_strlen_zero(ast_strip(chunk))) {
330 if (initfield && !strcmp(initfield, fieldnames[i])) {
331 ast_category_rename(cat, chunk);
333 var = ast_variable_new(fieldnames[i], chunk);
334 ast_variable_append(cat, var);
338 ast_category_append(cfg, cat);
343 "Postgresql RealTime: Could not find any rows in table %s.\n", table);
346 ast_mutex_unlock(&pgsql_lock);
352 static int update_pgsql(const char *database, const char *table, const char *keyfield,
353 const char *lookup, va_list ap)
355 PGresult *result = NULL;
358 const char *newparam, *newval;
361 ast_log(LOG_WARNING, "Postgresql RealTime: No table specified.\n");
365 /* Get the first parameter and first value in our list of passed paramater/value pairs */
366 newparam = va_arg(ap, const char *);
367 newval = va_arg(ap, const char *);
368 if (!newparam || !newval) {
370 "Postgresql RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
378 /* Create the first part of the query using the first parameter/value pairs we just extracted
379 If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
381 snprintf(sql, sizeof(sql), "UPDATE %s SET %s = '%s'", table, newparam, newval);
382 while ((newparam = va_arg(ap, const char *))) {
383 newval = va_arg(ap, const char *);
384 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s = '%s'", newparam,
388 snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield,
391 ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql);
393 /* We now have our complete statement; Lets connect to the server and execute it. */
394 ast_mutex_lock(&pgsql_lock);
395 if (!pgsql_reconnect(database)) {
396 ast_mutex_unlock(&pgsql_lock);
400 if (!(result = PQexec(pgsqlConn, sql))) {
402 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
403 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
404 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
405 PQerrorMessage(pgsqlConn));
406 ast_mutex_unlock(&pgsql_lock);
409 ExecStatusType result_status = PQresultStatus(result);
410 if (result_status != PGRES_COMMAND_OK
411 && result_status != PGRES_TUPLES_OK
412 && result_status != PGRES_NONFATAL_ERROR) {
414 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
415 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
416 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
417 PQresultErrorMessage(result), PQresStatus(result_status));
418 ast_mutex_unlock(&pgsql_lock);
423 numrows = atoi(PQcmdTuples(result));
424 ast_mutex_unlock(&pgsql_lock);
426 ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows,
429 /* From http://dev.pgsql.com/doc/pgsql/en/pgsql-affected-rows.html
430 * An integer greater than zero indicates the number of rows affected
431 * Zero indicates that no records were updated
432 * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.)
436 return (int) numrows;
441 static struct ast_config *config_pgsql(const char *database, const char *table,
442 const char *file, struct ast_config *cfg,
445 PGresult *result = NULL;
447 struct ast_variable *new_v;
448 struct ast_category *cur_cat = NULL;
451 int last_cat_metric = 0;
455 if (!file || !strcmp(file, RES_CONFIG_PGSQL_CONF)) {
456 ast_log(LOG_WARNING, "Postgresql RealTime: Cannot configure myself.\n");
460 snprintf(sql, sizeof(sql),
461 "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id",
464 ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sql);
466 /* We now have our complete statement; Lets connect to the server and execute it. */
467 ast_mutex_lock(&pgsql_lock);
468 if (!pgsql_reconnect(database)) {
469 ast_mutex_unlock(&pgsql_lock);
473 if (!(result = PQexec(pgsqlConn, sql))) {
475 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
476 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
477 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
478 PQerrorMessage(pgsqlConn));
479 ast_mutex_unlock(&pgsql_lock);
482 ExecStatusType result_status = PQresultStatus(result);
483 if (result_status != PGRES_COMMAND_OK
484 && result_status != PGRES_TUPLES_OK
485 && result_status != PGRES_NONFATAL_ERROR) {
487 "Postgresql RealTime: Failed to query database. Check debug for more info.\n");
488 ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
489 ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
490 PQresultErrorMessage(result), PQresStatus(result_status));
491 ast_mutex_unlock(&pgsql_lock);
496 if ((num_rows = PQntuples(result)) > 0) {
497 int numFields = PQnfields(result);
500 char **fieldnames = NULL;
502 ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows);
504 if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
505 ast_mutex_unlock(&pgsql_lock);
509 for (i = 0; i < numFields; i++)
510 fieldnames[i] = PQfname(result, i);
512 for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
513 char *field_category = PQgetvalue(result, rowIndex, 0);
514 char *field_var_name = PQgetvalue(result, rowIndex, 1);
515 char *field_var_val = PQgetvalue(result, rowIndex, 2);
516 char *field_cat_metric = PQgetvalue(result, rowIndex, 3);
517 if (!strcmp(field_var_name, "#include")) {
518 if (!ast_config_internal_load(field_var_val, cfg, 0)) {
520 ast_mutex_unlock(&pgsql_lock);
526 if (strcmp(last, field_category) || last_cat_metric != atoi(field_cat_metric)) {
527 cur_cat = ast_category_new(field_category);
530 strcpy(last, field_category);
531 last_cat_metric = atoi(field_cat_metric);
532 ast_category_append(cfg, cur_cat);
534 new_v = ast_variable_new(field_var_name, field_var_val);
535 ast_variable_append(cur_cat, new_v);
539 "Postgresql RealTime: Could not find config '%s' in database.\n", file);
543 ast_mutex_unlock(&pgsql_lock);
548 static struct ast_config_engine pgsql_engine = {
550 .load_func = config_pgsql,
551 .realtime_func = realtime_pgsql,
552 .realtime_multi_func = realtime_multi_pgsql,
553 .update_func = update_pgsql
556 static int load_module(void *mod)
560 ast_mutex_lock(&pgsql_lock);
562 if (!pgsql_reconnect(NULL)) {
564 "Postgresql RealTime: Couldn't establish connection. Check debug.\n");
565 ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
566 PQerrorMessage(pgsqlConn));
569 ast_config_engine_register(&pgsql_engine);
570 if (option_verbose) {
571 ast_verbose("Postgresql RealTime driver loaded.\n");
573 ast_cli_register(&cli_realtime_pgsql_status);
575 ast_mutex_unlock(&pgsql_lock);
580 static int unload_module(void *mod)
582 /* Aquire control before doing anything to the module itself. */
583 ast_mutex_lock(&pgsql_lock);
589 ast_cli_unregister(&cli_realtime_pgsql_status);
590 ast_config_engine_deregister(&pgsql_engine);
591 if (option_verbose) {
592 ast_verbose("Postgresql RealTime unloaded.\n");
595 STANDARD_HANGUP_LOCALUSERS;
597 /* Unlock so something else can destroy the lock. */
598 ast_mutex_unlock(&pgsql_lock);
603 static int reload(void *mod)
605 /* Aquire control before doing anything to the module itself. */
606 ast_mutex_lock(&pgsql_lock);
614 if (!pgsql_reconnect(NULL)) {
616 "Postgresql RealTime: Couldn't establish connection. Check debug.\n");
617 ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
618 PQerrorMessage(pgsqlConn));
621 ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n");
623 /* Done reloading. Release lock so others can now use driver. */
624 ast_mutex_unlock(&pgsql_lock);
629 int parse_config(void)
631 struct ast_config *config;
634 config = ast_config_load(RES_CONFIG_PGSQL_CONF);
637 if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
639 "Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
640 strcpy(dbuser, "asterisk");
642 ast_copy_string(dbuser, s, sizeof(dbuser));
645 if (!(s = ast_variable_retrieve(config, "general", "dbpass"))) {
647 "Postgresql RealTime: No database password found, using 'asterisk' as default.\n");
648 strcpy(dbpass, "asterisk");
650 ast_copy_string(dbpass, s, sizeof(dbpass));
653 if (!(s = ast_variable_retrieve(config, "general", "dbhost"))) {
655 "Postgresql RealTime: No database host found, using localhost via socket.\n");
658 ast_copy_string(dbhost, s, sizeof(dbhost));
661 if (!(s = ast_variable_retrieve(config, "general", "dbname"))) {
663 "Postgresql RealTime: No database name found, using 'asterisk' as default.\n");
664 strcpy(dbname, "asterisk");
666 ast_copy_string(dbname, s, sizeof(dbname));
669 if (!(s = ast_variable_retrieve(config, "general", "dbport"))) {
671 "Postgresql RealTime: No database port found, using 5432 as default.\n");
677 if (dbhost && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
679 "Postgresql RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
680 strcpy(dbsock, "/tmp/pgsql.sock");
682 ast_copy_string(dbsock, s, sizeof(dbsock));
685 ast_config_destroy(config);
688 ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost);
689 ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport);
691 ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock);
693 ast_log(LOG_DEBUG, "Postgresql RealTime User: %s\n", dbuser);
694 ast_log(LOG_DEBUG, "Postgresql RealTime Password: %s\n", dbpass);
695 ast_log(LOG_DEBUG, "Postgresql RealTime DBName: %s\n", dbname);
700 static const char *description(void)
702 return "Postgresql RealTime Configuration Driver";
706 static const char *key(void)
708 return ASTERISK_GPL_KEY;
711 static int pgsql_reconnect(const char *database)
713 char my_database[50];
715 ast_copy_string(my_database, S_OR(database, dbname), sizeof(my_database));
717 /* mutex lock should have been locked before calling this function. */
719 if (pgsqlConn && PQstatus(pgsqlConn) != CONNECTION_OK) {
724 if ((!pgsqlConn) && (dbhost || dbsock) && dbuser && dbpass && my_database) {
725 char *connInfo = NULL;
726 unsigned int size = 100 + strlen(dbhost)
729 + strlen(my_database);
731 if (!(connInfo = ast_malloc(size)))
734 sprintf(connInfo, "host=%s port=%d dbname=%s user=%s password=%s",
735 dbhost, dbport, my_database, dbuser, dbpass);
736 ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
737 pgsqlConn = PQconnectdb(connInfo);
738 ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
741 ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn);
743 ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n");
744 connect_time = time(NULL);
748 "Postgresql RealTime: Failed to connect database server %s on %s. Check debug for more info.\n",
750 ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
751 PQresultErrorMessage(NULL));
755 ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n");
760 static int realtime_pgsql_status(int fd, int argc, char **argv)
762 char status[256], status2[100] = "";
763 int ctime = time(NULL) - connect_time;
765 if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
767 snprintf(status, 255, "Connected to %s@%s, port %d", dbname, dbhost, dbport);
769 snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
771 snprintf(status, 255, "Connected to %s@%s", dbname, dbhost);
774 if (dbuser && *dbuser) {
775 snprintf(status2, 99, " with username %s", dbuser);
778 if (ctime > 31536000) {
779 ast_cli(fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n",
780 status, status2, ctime / 31536000, (ctime % 31536000) / 86400,
781 (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
782 } else if (ctime > 86400) {
783 ast_cli(fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status,
784 status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60,
786 } else if (ctime > 3600) {
787 ast_cli(fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2,
788 ctime / 3600, (ctime % 3600) / 60, ctime % 60);
789 } else if (ctime > 60) {
790 ast_cli(fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60,
793 ast_cli(fd, "%s%s for %d seconds.\n", status, status2, ctime);
796 return RESULT_SUCCESS;
798 return RESULT_FAILURE;
802 STD_MOD(MOD_0, reload, NULL, NULL);