<p>Benjamin Keith Ford has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/5929">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">manager: Fix AMI "Queues" action to output text in correct format.<br><br>When sending the "Queues" action to Asterisk via the manager interface,<br>it outputs the same text that the Asterisk CLI outputs when running a<br>"queue show" command, which does not conform with the AMI spec. This<br>fix corrects the output format so that it is uniform with other AMI<br>outputs.<br><br>ASTERISK-27073<br>Reported by: Brian<br><br>Change-Id: Id11743859758255b69cc3a557750d7a56c6d16f8<br>---<br>M apps/app_queue.c<br>1 file changed, 72 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/29/5929/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_queue.c b/apps/app_queue.c<br>index f158a4c..15a9a04 100644<br>--- a/apps/app_queue.c<br>+++ b/apps/app_queue.c<br>@@ -9733,10 +9733,79 @@<br> */<br> static int manager_queues_show(struct mansession *s, const struct message *m)<br> {<br>- static const char * const a[] = { "queue", "show" };<br>+ time_t now;<br>+ int q_items = 0;<br>+ const char *id = astman_get_header(m,"ActionID");<br>+ char idText[256];<br>+ struct call_queue *q;<br>+ float sl = 0;<br>+ struct member *mem;<br>+ struct ao2_iterator queue_iter;<br>+ struct ao2_iterator mem_iter;<br> <br>- __queues_show(s, -1, 2, a);<br>- astman_append(s, "\r\n\r\n"); /* Properly terminate Manager output */<br>+ astman_send_listack(s, m, "Queue list will follow", "start");<br>+ time(&now);<br>+ idText[0] = '\0';<br>+ if (!ast_strlen_zero(id)) {<br>+ snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);<br>+ }<br>+<br>+ queue_iter = ao2_iterator_init(queues, 0);<br>+ while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {<br>+ ao2_lock(q);<br>+<br>+ sl = ((q->callscompleted > 0) ? 100 * ((float)q->callscompletedinsl / (float)q->callscompleted) : 0);<br>+ astman_append(s, "Event: QueueParams\r\n"<br>+ "Queue: %s\r\n"<br>+ "Max: %d\r\n"<br>+ "Strategy: %s\r\n"<br>+ "Calls: %d\r\n"<br>+ "Holdtime: %d\r\n"<br>+ "Talktime: %d\r\n"<br>+ "Completed: %d\r\n"<br>+ "Abandoned: %d\r\n"<br>+ "ServiceLevel: %d\r\n"<br>+ "ServicelevelPerf: %2.1f\r\n"<br>+ "Weight: %d\r\n"<br>+ "%s"<br>+ "\r\n",<br>+ q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted,<br>+ q->callsabandoned, q->servicelevel, sl, q->weight, idText);<br>+ ++q_items;<br>+<br>+ /* List Queue Members */<br>+ mem_iter = ao2_iterator_init(q->members, 0);<br>+ while ((mem = ao2_iterator_next(&mem_iter))) {<br>+ astman_append(s, "Event: QueueMember\r\n"<br>+ "Queue: %s\r\n"<br>+ "Name: %s\r\n"<br>+ "Location: %s\r\n"<br>+ "StateInterface: %s\r\n"<br>+ "Membership: %s\r\n"<br>+ "Penalty: %d\r\n"<br>+ "CallsTaken: %d\r\n"<br>+ "LastCall: %d\r\n"<br>+ "LastPause: %d\r\n"<br>+ "InCall: %d\r\n"<br>+ "Status: %d\r\n"<br>+ "Paused: %d\r\n"<br>+ "PausedReason: %s\r\n"<br>+ "%s"<br>+ "\r\n",<br>+ q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",<br>+ mem->penalty, mem->calls, (int)mem->lastcall, (int)mem->lastpause, mem->starttime ? 1 : 0, mem->status,<br>+ mem->paused, mem->reason_paused, idText);<br>+ ++q_items;<br>+ ao2_ref(mem, -1);<br>+ }<br>+ ao2_iterator_destroy(&mem_iter);<br>+ ao2_unlock(q);<br>+ queue_t_unref(q, "Done with iterator");<br>+ }<br>+ ao2_iterator_destroy(&queue_iter);<br>+<br>+ astman_send_list_complete_start(s, m, "QueuesComplete", q_items);<br>+ astman_send_list_complete_end(s);<br> <br> return RESULT_SUCCESS;<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5929">change 5929</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/5929"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id11743859758255b69cc3a557750d7a56c6d16f8 </div>
<div style="display:none"> Gerrit-Change-Number: 5929 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Benjamin Keith Ford <bford@digium.com> </div>