QueueMetrics forum
QueueMetrics => Scripting QueueMetrics => Topic started by: barryf on December 10, 2007, 11:25:20
-
Hi,
Here is a small script to grab the calls waiting and Agent information for a given queue from the QueueMetrics XML-RPC service and create a simple display for use on a wallboard.
Display colours will change from Green to Yellow to Red depending on Calls waiting, Ready Agents. Will also sound an alarm.
This has proved useful in a large callcentre where the standard QM RT monitoring screen is too detailed and hard to see from a distance.
Screenshots:
http://www.flantel.com/qm/qmon1.jpg (http://www.flantel.com/qm/qmon1.jpg)
http://www.flantel.com/qm/qmon2.jpg (http://www.flantel.com/qm/qmon2.jpg)
Get the code here:
http://www.flantel.com/qm/qmon.php.txt (http://www.flantel.com/qm/qmon.php.txt)
Feel free to use it, improve it, just share your changes!
-Barry Flanagan
-
Super cool ;D how do you set up the script?
-
Super cool ;D how do you set up the script?
Basic instructions are in comments in the script.
To use, simply define the queues you want to monitor as $queueid, and set the QM ROBOT user and PASS, as well as the IP address of your QM server.
I allow passing of a GET variable within the URL to select the queue to monitor, which is then evaluated in the switch statement. Just define $queueid to contain the Asterisk queue names (not the QM aliases). So just change the $queuename and $queueid in the switch statement to suit your needs.
If you want to set a default queue for when no GET is included (i.e. /qmon.php?queue=QUEUENAME) then define this in $defaultqueue.
// Set which queue you want to default to when none is specified
$defaultqueue = 'verification';
// Allow seting of the queue to monitor, and the refresh time.
isset($_REQUEST['refresh'])?$refresh = $_REQUEST['refresh']:$refresh=120;
isset($_REQUEST['queue'])?$queuereq = $_REQUEST['queue']:$queuereq=$defaultqueue;
// Depending on which queue was requested, set $queueid for passing to queuemetrics.
switch ($queuereq) {
case 'verification':
$queueid = "301|310|311|312";
$queuename='Dublin Verification';
break ;;
case 'inbound':
$queueid = "401|402|403|404|405|406|407|408|409|410|411|412";
$queuename='Inbound';
break;;
case 'outbound':
$queueid = "Outbound";
$queuename='Outbound';
break ;;
}
// Set up the XML-RPC instance.
require_once 'XML/RPC.php';
$qm_server = "127.0.0.1"; // the QueueMetrics server address
$qm_port = "8080"; // the port QueueMetrics is running on
$qm_webapp = "queuemetrics"; // the webapp name for QueueMetrics
Hope this helps.
-Barry Flanagan
-
That's great! ;) :D
-
???
I'm unable to get this script to work.
I receive this error:
Fault Code: 5 Fault Reason: Didn't receive 200 OK from remote server. (HTTP/1.1 302 Moved Temporarily)
My guess is its looking for "/$qm_webapp/xmlrpc.do". I tried looking through all of the queuemetrics directories but I'm cant find it anywhere.
Any ideas?
-
I'm unable to get this script to work.
I receive this error:
Fault Code: 5 Fault Reason: Didn't receive 200 OK from remote server. (HTTP/1.1 302 Moved Temporarily)
My guess is its looking for "/$qm_webapp/xmlrpc.do". I tried looking through all of the queuemetrics directories but I'm cant find it anywhere.
Any ideas?
No idea. Are you using a very recent version of QM? The XML-RPC only kicked in in later versions.
-Barry
-
No idea. Are you using a very recent version of QM? The XML-RPC only kicked in in later versions.
-Barry
Using QM 1.4.2.
One question. Does this script have to be run over Tomcat? I'm attempting to run it on a different server with Apache2, php and pear installed.
-
;D ;D ;D
I got it. It took some digging. Looks like I was missing Xerces.
I found this post:
http://astrecipes.net/index.php?from=226&q=astrecipes/xml-rpc+not+working
Hope this helps answer any other questions.
-
One question. Does this script have to be run over Tomcat? I'm attempting to run it on a different server with Apache2, php and pear installed.
No there are no requirements for the script, as it's a plain PHP script that just interfaces to QM. (BTW, if you plan to fetch large datasets, make sure you don't get smothered by PHP's run-time and memory limits)
-
This wallboard is awesome. I've changed the colors around and it makes our call center look very professional. I highly recommend it!
One thought on adding to it. How hard would it be to grab the current days SLA percentage for All Queues selected and display it in one of the upper corners?
-
Hello,
Not sure if anyone was interested, I made a few slight adjustments and a few colour/design changes.
http://my.computr.co.uk/downloads/qmon.txt (to change queuename use qmon.php?queue=queueone|queuetwo|queuethree etc)
http://my.computr.co.uk/downloads/style.css.txt
http://my.computr.co.uk/downloads/image1.jpg
http://my.computr.co.uk/downloads/image2.jpg
http://my.computr.co.uk/downloads/image3.jpg
I also found I had the same error that moa had with Xerces, basically followed the instructions and viola, it all worked. I have Queuemetrics 1.4.2
Another problem I found was:
$params_rt = array(
new XML_RPC_Value($queuename),
new XML_RPC_Value("USER"),
new XML_RPC_Value("PASSWORD"),
new XML_RPC_Value(""),
new XML_RPC_Value(""),
$req_blocks_rt
);
Where $queuename was $queueid but after changing it to $queuename it worked for me... no idea why.
Anyway,
Enjoy.
Byron
-
Looks really cool! :D
the value you pass in the XML-RPC call is the queue_id in Asterisk (that is the 'raw' queue name) or a set of queue names, pipe separated (eg q1|q2|q3)
Thanks!
-
Another problem I found was:
$params_rt = array(
new XML_RPC_Value($queuename),
new XML_RPC_Value("USER"),
new XML_RPC_Value("PASSWORD"),
new XML_RPC_Value(""),
new XML_RPC_Value(""),
$req_blocks_rt
);
Where $queuename was $queueid but after changing it to $queuename it worked for me... no idea why.
That's because you took out the switch statement:
// Set which queue you want to default to when none is specified
$defaultqueue = 'verification';
// Allow seting of the queue to monitor, and the refresh time.
isset($_REQUEST['refresh'])?$refresh = $_REQUEST['refresh']:$refresh=120;
isset($_REQUEST['queue'])?$queuereq = $_REQUEST['queue']:$queuereq=$defaultqueue;
// Depending on which queue was requested, set $queueid for passing to queuemetrics.
switch ($queuereq) {
case 'verification':
$queueid = "301|310|311|312";
$queuename='Dublin Verification';
break ;;
case 'inbound':
$queueid = "401|402|403|404|405|406|407|408|409|410|411|412";
$queuename='Inbound';
break;;
case 'outbound':
$queueid = "Outbound";
$queuename='Outbound';
break ;;
}
I use this so that I can pass a queue GET parameter such as "inbound" which then sets
$queueid= "401|402|403|404|405|406|407|408|409|410|411|412";
which contains the real Asterisk queue names separated by pipes, and also sets $queuename for display at the top.
-Barry Flanagan
-
Hi Barry,
For sure, I realised what your switch/case was for but I didn't need it in my case. Apologies if it looked like what I did made it seem as if the code broke, this was not the case, in fact the truth is when I used the queue id's in the query string it didn't work, using the queue names it did work in my case, hence the reason for bringing up the $queueid and $queuename etc.
Anyways, the many thing is it works and all that is thanks to your efforts, many thanks.
Regards
Byron
-
The screen shots look great. But where does this script go (directory) or is it appended into an existing script? How does it get called?
Thanks in advance!
-Roque
-
Hello,
Does somebody have following error?
Fault Code: 2 Fault Reason: Invalid return payload: enabling debugging to examine incoming payload
Thanks
-
Where do you get that? in PHP?
-
Yes, the fault is generated by the following php code:
echo 'Fault Code: ' . $resp_rt->faultCode() . "\n";
-
I tested this script today and all went well, except that nothing is happening or displayed as expected at the "Calls Waiting" and the "Agents Status" area. I could see a display of Agents logged on/Available or on a call below as expected.
Please can anyone point me to what am doing wrong or still need to do. Here is my script;
$defaultqueue = 'CustomerCare';
// Allow setting of the queue to monitor, and the refresh time.
isset($_REQUEST['refresh'])? $refresh = $_REQUEST['refresh'] : $refresh=10;
isset($_REQUEST['queue'])?$queureq = $_REQUEST['queue']:$queuereq=$defaultqueue;
$queueid = "4000";
$queuename = 'Customer Care';
// Set up the XML-RPC instance.
require_once 'XML/RPC.php';
$qm_server = "127.0.0.1"; // the QueueMetrics server address
$qm_port = "8080"; // the port QueueMetrics is running on
$qm_webapp = "queue"; // the webapp name for QueueMetricsi
$req_blocks_rt = new XML_RPC_Value(array(
new XML_RPC_Value("RealtimeDO.RTRiassunto"),
new XML_RPC_Value("RealtimeDO.RTCallsBeingProc"),
new XML_RPC_Value("RealtimeDO.RTAgentsLoggedIn")
), "array");
// general invocation parameters. Set the USER and PASSWORD to a QM user with ROBOT key
$params_rt = array(
new XML_RPC_Value($queueid),
new XML_RPC_Value("wallboard"),
new XML_RPC_Value("abcd12345"),
new XML_RPC_Value(""),
new XML_RPC_Value(""),
$req_blocks_rt
);
as you can see, I am monitoring only one queue, so I don't need the switch statement. I hope am right?
Cheers to All.
-
I tested this script today and all went well, except that nothing is happening or displayed as expected at the "Calls Waiting" and the "Agents Status" area. I could see a display of Agents logged on/Available or on a call below as expected.
I'm getting the same thing so I am thinking something with the XML changed. I will post if I get it figured out. I plan on taking a deeper look when I get a chance.
-
Hi ALL,
Any clue on getting this resolved.
Regards.
-
Hi kayodea
I work with the 2ns example from byronsmith because we like the layout.
I found some write errors in parts of the code
He uses $queue['All selected']['nagents']It must be $queue['all selected']['nagents']
In the HTML part I replaced the $nagents wit $queue['all selected']['nagents'] to get some 1st results.
this workes but only with 1 queue
I made equal changes to the other 2 number parts
I am still working more on it but get results now
Hope this helps
-
Thanks Bevort. That helps the bottom part.
It appears at least with 1.4.6 that RTCallsBeingProc is not working or this script does not use it right. Anyone using one of these scripts and 1.4.6 with success?
-
RTCallsBeingProc is working just fine after the upgrade from 1.4.2 to 1.4.7 last night. I did have to do Bevorts change with the "all selected" case. Here's the code for RTCallsBeingProc:
Here's the call to it:
$agentStatus = getCurrentCalls( "RealtimeDO.RTCallsBeingProc", $blocks_rt, $agent );
And here is getCurrentCalls
function getCurrentCalls( $blockname, $blocks, $agent ) {
global $agent;
$block = $blocks[$blockname];
for ( $r = 1; $r < sizeof( $block ) ; $r++ ) {
$agent[$block[$r][6]]['caller'] = $block[$r][2];
$agent[$block[$r][6]]['entered'] = $block[$r][3];
$agent[$block[$r][6]]['waiting'] = $block[$r][4];
$agent[$block[$r][6]]['duration'] = $block[$r][5];
$agent[$block[$r][6]]['queue'] = $block[$r][1];
}
$agentStatus = '';
$rowcount=1;
for ( $r = 0; $r < sizeof( $agent ) ; $r++ ) {
$agent = array_values($agent);
if ($rowcount == 1){
$rowcolor = "lightgray";
$rowcount++;
} elseif ($rowcount == 2) {
$rowcolor = "white";
$rowcount = 1;
}
if ($agent[$r]['duration'] != '') {
$status = $agent[$r]['entered'] . " Call " . " (" . $agent[$r]['duration'] . ")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "maroon";
$blinkon = '';
$blinkoff = '';
}
elseif ($agent[$r]['onpause'] != '-') {
$pauseTime=substr_replace($agent[$r]['onpause'],"",5);
$pauseWhat=substr_replace($agent[$r]['onpause'],"",0,6);
$pauseDuration = time() - strtotime($pauseTime);
if($pauseWhat == "Break" && sec2hms($pauseDuration) > "0:10:00"){
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "red";
$blinkon = '<blink>';
$blinkoff = '</blink>';
}elseif($pauseWhat == "Lunch" && sec2hms($pauseDuration) >= "0:60:00"){
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "red";
$blinkon = '<blink>';
$blinkoff = '</blink>';
}elseif($pauseWhat == "ACW" && sec2hms($pauseDuration) >= "0:01:00"){
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "red";
$blinkon = '<blink>';
$blinkoff = '</blink>';
}elseif($pauseWhat == "Meeting" && sec2hms($pauseDuration) >= "0:60:00"){
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "blue";
$blinkon = '';
$blinkoff = '';
}elseif($pauseWhat == "Extra Duties" && sec2hms($pauseDuration) >= "0:10:00"){
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "red";
$blinkon = '<blink>';
$blinkoff = '</blink>';
}
else{
$status = $agent[$r]['onpause'] . " (". sec2hms($pauseDuration) .")";
$bgcolor3 = $rowcolor;
$fontcolor3 = "blue";
$blinkon = '';
$blinkoff = '';
}
}
else {
$status = "Available";
$bgcolor3 = $rowcolor;
$fontcolor3 = "black";
$blinkon = '';
$blinkoff = '';
}
$agentStatus .="<tr bgcolor=\"" . $rowcolor . "\" style=\"color:black; font-size: 30px;\"><td> </td><td style=\"color:" . $fontcolor3 . ";\" bgcolor=\"" . $bgcolor3 . "\" >".$blinkon."" . $agent[$r]['name'] . "".$blinkoff."</td><td style=\"color:" . $fontcolor3 . ";\" bgcolor=\"" . $bgcolor3 . "\" >".$blinkon."" . $status . "".$blinkoff."</td><td>" . $agent[$r]['queue'] . "</td><td>" . substr_replace($agent[$r]['caller'],"",10) . "</td></tr>";
}
return $agentStatus;
}
Most of it is the original code from Barry. You might notice I added extra stuff to handle the techs on pause. It makes the text start blinking if they take to long of a break. I hope this helps.
-
Cool man!
-
Anybody wants to contribuite this script to the "QueueMetrics add-ons" collection? see http://forum.queuemetrics.com/index.php?board=14.0
-
???
Quick question, has anyone figured out how to make the function getAgentLoggedIn(); only return the agents that are logged into the requested queues ? I've got four different wallboards, one for each department. Only problem is it shows every person that is logged into the phones, it doesn't matter if they are associated with the department queues or not.
-
Well, guess I should try a few things before I post. Here's a quick and dirty way:
function getAgentLoggedIn( $blockname, $blocks ) {
$agent = array();
$block = $blocks[$blockname];
for ( $r = 1; $r < sizeof( $block ) ; $r++ ) {
//$queues = $block[$r][4];
if($block[$r][4])
{
$agent[$block[$r][1]]['name'] = $block[$r][1];
$agent[$block[$r][1]]['lastlogin'] = $block[$r][3];
$agent[$block[$r][1]]['queues'] = $block[$r][4];
$agent[$block[$r][1]]['extension'] = $block[$r][5];
$agent[$block[$r][1]]['onpause'] = $block[$r][6];
$agent[$block[$r][1]]['srv'] = $block[$r][7];
$agent[$block[$r][1]]['lastcall'] = $block[$r][8];
$agent[$block[$r][1]]['onqueue'] = $block[$r][9];
$agent[$block[$r][1]]['caller'] = '----------';
$agent[$block[$r][1]]['entered'] = null;
$agent[$block[$r][1]]['waiting'] = null;
$agent[$block[$r][1]]['duration'] = null;
}
}
return $agent;
}
-
Really man, why not contribute the script to the sourceforge project? :)
-
Really man, why not contribute the script to the sourceforge project? :)
No one has contributed this yet? I'll contribute it once I figure out this last problem. Here's the issue:
We have queueA and queueB, splitting those up is easy. But when you have a supervisor that is logged into both queues. And he/she is on a call on queueA, he is showing up available on the queueB page. I'm assuming that this has to do with QM and how it displays the users on the realtime stats page. Any suggestions ?
-
I think that you should run a report for all the queues, so you see the correct status of the supervisor, and then filter off what you don't need.
-
Hi, I've tried this sample scripts and even read the rest of the forum replies.
I copied the two given samples and put it on /var/www/html directory. When I run this, i received this message:
Fault Code: 5 Fault Reason: Didn't receive 200 OK from remote server. (HTTP/1.1 404 /queuemetrics-1.5.0/xmlrpc.do)
is this all about xml-rpc thing?
Thanks in advance.
-
Have you enabled the "robots" user?
Are you sure you are pointing to the correct QM instance?
-
Which file should i replace with the script posted here to use the custom wallboard? Or should i add it to an excisting script (if yes, which?)
-
You just install the PHP script where you want and configure it to access your QM instance.
-
Hi
the qmon.php is in /var/www/html/user
i changed following lines:
$defaultqueue = 'Inbound';
case 'inbound':
$queueid = "600|601|602|603|604|605";
$queuename='Inbound';
$qm_server = "192.168.50.17"; // the QueueMetrics server address
$qm_port = "8080"; // the port QueueMetrics is running on
$qm_webapp = "queuemetrics"; // the webapp name for QueueMetrics
new XML_RPC_Value($queueid),
new XML_RPC_Value("USER"),
new XML_RPC_Value("PASSWORD"),
new XML_RPC_Value("qmon"),
new XML_RPC_Value("*********"),
$req_blocks_rt
qmon is a user in QM configuration as ROBOT
But don't work....
btw in the script there is following line: "$cli_rt = new XML_RPC_Client("/$qm_webapp/xmlrpc.do", $qm_server,$qm_port);
" ... but i can't find any xmlrpc.do in my server.
thanks a lot
bye
Moreno
-
What error do you get in PHP?
The URLs that look like .do are "virtual" - they are not linked to a file.
-
I don't see any error
just the complete webpage, but without data on top ... just the bottom part (Agent Status Last Call Current Caller)
Calls Waiting and agent status are empty
PS: i use static agents
bye
-
Can you post a screenshot?
-
Exactly like this one :http://www.flantel.com/qm/qmon1.jpg
but without any number in the first part.
the part below it's ok
bye
M.
-
I have exactly the same situation. The data about the agents is shown, but not the numbers of calls waiting and agents available (Upper screen) Does anyone know why this is?
I also would like to add the status 'pause' to the agents, anyone who knows how to add this option in the script?
-
You have to edit the script, likely the positions have changed.
-
I didn't change anything in the script, except the names of the queues and the user for robot, so that's why it's strange that i dont get that data. Anything that can solve this?
-
Yes but the script is for a very old version of QM - maybe it's not reading data it's expected to read. You should ask its author for help.
-
Hi Guys,
Anyone knows in windows how can i put this kind of script working ?
Many thanks
-
Hi
Never done it, but so long as you have php and the necessary php modules (xmlrpc for example) it should work easily enough.
-Barry
-
it's great.
I found that the waiting call isn't equal to the QM realtime wallboard sometimes,does it the bug of xmlrpc?
-
No they are computed exactly in the same manner.
-
Tried the script and run into an error saying 'Undefined index 'All selected' line 87 etc...
// Get the waiting calls and number of agents for these queues
$waitqueue = $queue['All selected']['waiting'];
$nagents = $queue['All selected']['nagents'];
$ragents = $queue['All selected']['ragents'];
Looks like it don't understand 'All selected'
Someone ever find the solution?
Ron