[asterisk-commits] qwell: trunk r43721 - /trunk/apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Sep 26 14:30:41 MST 2006


Author: qwell
Date: Tue Sep 26 16:30:41 2006
New Revision: 43721

URL: http://svn.digium.com/view/asterisk?rev=43721&view=rev
Log:
Add QueueSummary manager action.
Gives "at a glance" information about a single queue, or all queues.

Issue #8035, patch by rgollent, slightly modified (formatting) by me.

Modified:
    trunk/apps/app_queue.c

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=43721&r1=43720&r2=43721&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue Sep 26 16:30:41 2006
@@ -3984,8 +3984,66 @@
 	return RESULT_SUCCESS;
 }
 
+/* Dump summary of queue info */
+static int manager_queues_summary(struct mansession *s, struct message *m)
+{
+	time_t now;
+	int qmemcount = 0;
+	int qmemavail = 0;
+	int qchancount = 0;
+	char *id = astman_get_header(m, "ActionID");
+	char *queuefilter = astman_get_header(m, "Queue");
+	char idText[256] = "";
+	struct call_queue *q;
+	struct queue_ent *qe;
+	struct member *mem;
+
+	astman_send_ack(s, m, "Queue summary will follow");
+	time(&now);
+	AST_LIST_LOCK(&queues);
+	if (!ast_strlen_zero(id))
+		snprintf(idText, 256, "ActionID: %s\r\n", id);
+        AST_LIST_TRAVERSE(&queues, q, list) {
+		ast_mutex_lock(&q->lock);
+
+		/* List queue properties */
+		if (ast_strlen_zero(queuefilter) || !strcmp(q->name, queuefilter)) {
+			/* List Queue Members */
+			for (mem = q->members; mem; mem = mem->next) {
+				if ((mem->status != AST_DEVICE_UNAVAILABLE) && (mem->status != AST_DEVICE_INVALID)) {
+					++qmemcount;
+					if (((mem->status == AST_DEVICE_NOT_INUSE) || (mem->status == AST_DEVICE_UNKNOWN)) && !(mem->paused)) {
+						++qmemavail;
+					}
+				}
+			}
+			for (qe = q->head; qe; qe = qe->next) {
+				++qchancount;
+			}
+			astman_append(s, "Event: QueueSummary\r\n"
+				"Queue: %s\r\n"
+				"LoggedIn: %d\r\n"
+				"Available: %d\r\n"
+				"Callers: %d\r\n" 
+				"HoldTime: %d\r\n"
+				"%s"
+				"\r\n",
+				q->name, qmemcount, qmemavail, qchancount, q->holdtime, idText);
+		}
+		ast_mutex_unlock(&q->lock);
+	}
+	astman_append(s,
+		"Event: QueueSummaryComplete\r\n"
+		"%s"
+		"\r\n", idText);
+
+	AST_LIST_UNLOCK(&queues);
+
+	return RESULT_SUCCESS;
+}
+
 /* Dump queue status */
-static int manager_queues_status( struct mansession *s, struct message *m )
+static int manager_queues_status(struct mansession *s, struct message *m)
 {
 	time_t now;
 	int pos;
@@ -4369,6 +4427,7 @@
 	res = ast_manager_unregister("QueueStatus");
 	res |= ast_manager_unregister("Queues");
 	res |= ast_manager_unregister("QueueStatus");
+	res |= ast_manager_unregister("QueueSummary");
 	res |= ast_manager_unregister("QueueAdd");
 	res |= ast_manager_unregister("QueueRemove");
 	res |= ast_manager_unregister("QueuePause");
@@ -4405,6 +4464,7 @@
 	res |= ast_register_application(app_ql, ql_exec, app_ql_synopsis, app_ql_descrip);
 	res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues");
 	res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status");
+	res |= ast_manager_register("QueueSummary", 0, manager_queues_summary, "Queue Summary");
 	res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue.");
 	res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue.");
 	res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable");



More information about the asterisk-commits mailing list