[Asterisk-Users] Is there a way to # of agents logged into a queue ?

C. Maj cmaj at freedomcorpse.info
Thu Jan 22 16:31:20 MST 2004


Nope, I'm an idiot.  Here's the patch :P

On Thu, 22 Jan 2004, Bill Hamel waxed:

> Hi Chris,
> 
> This sounds what I am looking for, many thanks !
> 
> Also, I do not see an attachment, the patch that is :)
> 
> I dont know if the list strips attachments, perhaps send it to my email address
> asterisk at hamel.net
> 
> Thanks again,
> -bh
> 
> 
> Quoting "C. Maj" <cmaj at freedomcorpse.info>:
> > I attached a patch I've been using to show the # of agents
> > (members) and callers on a per queue basis.  It adds a new
> > manager command, "AgentQueues".  It returns on the manager
> > interface the following for each queue:
> > 
> >     Queue: queuename
> >     Agents: #
> >     Callers: #
> > 
> > There's another manager command, "QueueStatus", that might be
> > what your are looking for.  There's also "Queues" but that
> > is a PITA to parse.  Fine if you just want to display it in
> > a text widget or something.
> > 
> > --Chris
> > 
> > 
> > -- 
> > 
> > Chris Maj <cmaj_hat_freedomcorpse_hot_info>
> > Pronunciation Guide:  Maj == May
> > Fingerprint: 43D6 799C F6CF F920 6623  DC85 C8A3 CFFE F0DE C146
> > 
> > _______________________________________________
> > Asterisk-Users mailing list
> > Asterisk-Users at lists.digium.com
> > http://lists.digium.com/mailman/listinfo/asterisk-users
> > To UNSUBSCRIBE or update options visit:
> >    http://lists.digium.com/mailman/listinfo/asterisk-users
> > 
> > -- 
> > This message has been scanned for viruses and
> > dangerous content by The CCIS.net MailScanner, and is
> > believed to be clean.
> > 
> > 
> > -- 
> > This message has been scanned for viruses and
> > dangerous content by the Bugs.Hamel.Net MailScanner, 
> > and appears to be clean.
> > 
> > 
> 
> 
> 

-- 

Chris Maj <cmaj_hat_freedomcorpse_hot_info>
Pronunciation Guide:  Maj == May
Fingerprint: 43D6 799C F6CF F920 6623  DC85 C8A3 CFFE F0DE C146
-------------- next part --------------
--- ../../../../asterisk/asterisk/apps/app_queue.c	2004-01-06 16:45:20.000000000 -0500
+++ app_queue.c	2004-01-22 11:05:49.000000000 -0500
@@ -1403,6 +1403,57 @@
 	return RESULT_SUCCESS;
 }
 
+static int agent_queues_show(int fd, int argc, char **argv)
+{
+	struct ast_call_queue *q;
+	struct queue_ent *qe;
+	struct member *mem;
+	time_t now;
+	char max[80];
+    int agents=0;
+    int callers=0;
+	
+	time(&now);
+	if (argc != 2)
+		return RESULT_SHOWUSAGE;
+	ast_mutex_lock(&qlock);
+	q = queues;
+	if (!q) {	
+		ast_mutex_unlock(&qlock);
+		ast_cli(fd, "No queues.\n");
+		return RESULT_SUCCESS;
+	}
+	while(q) {
+		ast_mutex_lock(&q->lock);
+		if (q->maxlen)
+			snprintf(max, sizeof(max), "%d", q->maxlen);
+		else
+			strcpy(max, "unlimited");
+		ast_cli(fd, "Queue: %s\r\n", q->name);
+		if (q->members) {
+            mem = q->members;
+            while (mem) {
+                mem = mem->next;
+                agents++;
+            }
+        }
+		ast_cli(fd, "Agents: %d\r\n", agents);
+		if (q->head) {
+            qe = q->head;
+            while (qe) {
+                qe = q->next;
+                callers++;
+            }
+        }
+		ast_cli(fd, "Callers: %d\r\n", callers);
+		ast_mutex_unlock(&q->lock);
+		q = q->next;
+	}
+	ast_mutex_unlock(&qlock);
+	ast_cli(fd, "\n");
+	return RESULT_SUCCESS;
+}
+
 /* JDG: callback to display queues status in manager */
 static int manager_queues_show( struct mansession *s, struct message *m )
 {
@@ -1410,6 +1461,11 @@
 	return queues_show( s->fd, 2, a );
 } /* /JDG */
 
+static int manager_agent_queues_show( struct mansession *s, struct message *m )
+{
+	char *a[] = { "show", "agentqueues" };
+	return agent_queues_show( s->fd, 2, a );
+}
 
 /* Dump queue status */
 static int manager_queues_status( struct mansession *s, struct message *m )
@@ -1473,6 +1529,7 @@
 	ast_cli_unregister(&cli_show_queues);
 	ast_manager_unregister( "Queues" );
 	ast_manager_unregister( "QueueStatus" );
+	ast_manager_unregister( "AgentQueues" );
 	return ast_unregister_application(app);
 }
 
@@ -1484,6 +1541,7 @@
 		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" );
+		ast_manager_register( "AgentQueues", 0, manager_agent_queues_show, "AgentQueues" );
 
 		// [PHM 06/26/03]
 		ast_register_application(app_aqm, aqm_exec, app_aqm_synopsis, app_aqm_descrip) ;


More information about the asterisk-users mailing list