diff options
author | Martin Pycko <martinp@digium.com> | 2004-02-03 16:59:04 +0000 |
---|---|---|
committer | Martin Pycko <martinp@digium.com> | 2004-02-03 16:59:04 +0000 |
commit | 4bef006566e08033c8732392770fdc25485101cb (patch) | |
tree | b2f4f3f35e447d24f0630d225b8aab16ccb1ccdf /apps/app_queue.c | |
parent | 860f35a7ab5a4abecb78e738191307db583430af (diff) |
Add "show queue <queue_name>" CLI command
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2122 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_queue.c')
-rwxr-xr-x | apps/app_queue.c | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index 446b26422..312cd43ec 100755 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1344,28 +1344,41 @@ static void reload_queues(void) ast_mutex_unlock(&qlock); } -static int queues_show(int fd, int argc, char **argv) +static int __queues_show(int fd, int argc, char **argv, int queue_show) { - struct ast_call_queue *q; + struct ast_call_queue *q, tmpq; struct queue_ent *qe; struct member *mem; int pos; time_t now; char max[80]; char calls[80]; - time(&now); - if (argc != 2) + if ((!queue_show && argc != 2) || (queue_show && argc != 3)) return RESULT_SHOWUSAGE; ast_mutex_lock(&qlock); q = queues; if (!q) { ast_mutex_unlock(&qlock); - ast_cli(fd, "No queues.\n"); + if (queue_show) + ast_cli(fd, "No such queue: %s.\n",argv[2]); + else + ast_cli(fd, "No queues.\n"); return RESULT_SUCCESS; } while(q) { ast_mutex_lock(&q->lock); + if (queue_show) { + if (strcasecmp(q->name, argv[2]) != 0) { + q = q->next; + ast_mutex_unlock(&q->lock); + if (!q) { + ast_cli(fd, "No such queue: %s.\n",argv[2]); + break; + } + continue; + } + } if (q->maxlen) snprintf(max, sizeof(max), "%d", q->maxlen); else @@ -1400,11 +1413,41 @@ static int queues_show(int fd, int argc, char **argv) ast_cli(fd, "\n"); ast_mutex_unlock(&q->lock); q = q->next; + if (queue_show) + break; } ast_mutex_unlock(&qlock); return RESULT_SUCCESS; } +static int queues_show(int fd, int argc, char **argv) +{ + return __queues_show(fd, argc, argv, 0); +} + +static int queue_show(int fd, int argc, char **argv) +{ + return __queues_show(fd, argc, argv, 1); +} + +static char *complete_queue(char *line, char *word, int pos, int state) +{ + struct ast_call_queue *q; + int which=0; + + ast_mutex_lock(&qlock); + q = queues; + while(q) { + if (!strncasecmp(word, q->name, strlen(word))) { + if (++which > state) + break; + } + q = q->next; + } + ast_mutex_unlock(&qlock); + return q ? strdup(q->name) : NULL; +} + /* JDG: callback to display queues status in manager */ static int manager_queues_show( struct mansession *s, struct message *m ) { @@ -1469,9 +1512,18 @@ static struct ast_cli_entry cli_show_queues = { { "show", "queues", NULL }, queues_show, "Show status of queues", show_queues_usage, NULL }; +static char show_queue_usage[] = +"Usage: show queue\n" +" Provides summary information on a specified queue.\n"; + +static struct ast_cli_entry cli_show_queue = { + { "show", "queue", NULL }, queue_show, + "Show status of a specified queue", show_queue_usage, complete_queue }; + int unload_module(void) { STANDARD_HANGUP_LOCALUSERS; + ast_cli_unregister(&cli_show_queue); ast_cli_unregister(&cli_show_queues); ast_manager_unregister( "Queues" ); ast_manager_unregister( "QueueStatus" ); @@ -1483,6 +1535,7 @@ int load_module(void) int res; res = ast_register_application(app, queue_exec, synopsis, descrip); if (!res) { + ast_cli_register(&cli_show_queue); ast_cli_register(&cli_show_queues); ast_manager_register( "Queues", 0, manager_queues_show, "Queues" ); ast_manager_register( "QueueStatus", 0, manager_queues_status, "Queue Status" ); |