Author Topic: Wallboard agent status with dynamic users.  (Read 6209 times)

Richarddb

  • Jr. Member
  • **
  • Posts: 57
  • Karma: 0
    • View Profile
Wallboard agent status with dynamic users.
« on: July 05, 2012, 14:07:14 »
Hi,

we have reinstalled queuemetrics but we are using dynamic agents now. How can I get the agent status back on the wallboard.

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Wallboard agent status with dynamic users.
« Reply #1 on: July 17, 2012, 11:54:06 »
What do you get now?

Richarddb

  • Jr. Member
  • **
  • Posts: 57
  • Karma: 0
    • View Profile
Re: Wallboard agent status with dynamic users.
« Reply #2 on: July 25, 2012, 14:55:26 »
Hi,

We only have the rdy agnt: on screen.



Normally we got the agent status on the wallboard but after the new queuemetrics installation we only get the ready agents.

and here the php script.

Quote
<?php
/*
  qmon.php
  Author: Barry Flanagan <barry AT flantel DOT com>
  Date: 21 Nov 2007
  Copyright Barry Flanagan 2007
 
  Small program 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.

*/

$defaultqueue = 'inbound';

require_once 'XML/RPC.php';

$qm_server = "XXXXXXXXXXXX"; // the QueueMetrics server address
$qm_port   = "8080";        // the port QueueMetrics is running on
$qm_webapp = "queuemetrics"; // the webapp name for QueueMetrics
isset($_REQUEST['refresh'])?$refresh = $_REQUEST['refresh']:$refresh=5;
isset($_REQUEST['queue'])?$queuereq = $_REQUEST['queue']:$queuereq=$defaultqueue;

switch ($queuereq) {
  case 'inbound':
    $queueids = "9000|9001|9002|9003|9004|9005|9006|9007|9008|9009|9010|9011|9012|9013|9014|9015|q-123";
   $outboundqueue = '';
    $queuename='inbound';
    break;;

  case 'outbound':
    $queueids = "q-123";
    $outboundqueue = '';
    $queuename='outbound';
    break ;;
}

?>
<html><head><meta http-equiv="refresh" content="<?php echo $refresh ?>"><title><?php echo $queuename . " Wallboard" ?></title></head><body marginheight=0 marginwidth=0>
<table width="100%" cellpadding=0 cellspacing=0 border="0">
  <tr>
<?php



$queuelist = array_merge(explode("|", $queueids),explode("|",$outboundqueue));

// Choose the Realtime nethods we want to query.
$req_blocks_rt = new XML_RPC_Value(array(
      new XML_RPC_Value("RealtimeDO.RTCallsBeingProc"),
      new  XML_RPC_Value("RealtimeDO.RTAgentsLoggedIn"),
      new XML_RPC_Value("RealtimeDO.RTRiassunto")
           ), "array");

// initialize the XML_RPC call
$params_rt = array(
     new XML_RPC_Value($queueids),
           new XML_RPC_Value("robot"),
           new XML_RPC_Value("robot"),
           new XML_RPC_Value(""),
           new XML_RPC_Value(""),
           $req_blocks_rt
       );

// Make the XML_RPC call       
$msg_rt = new XML_RPC_Message('QM.realtime', $params_rt);
$cli_rt = new XML_RPC_Client("/$qm_webapp/xmlrpc.do", $qm_server,$qm_port);
//$cli_rt->setDebug(1);
$resp_rt = $cli_rt->send($msg_rt);
// Make sure it was successful
if (!$resp_rt) {
    echo 'Communication error: ' . $cli_rt->errstr;
    exit;
}
if ($resp_rt->faultCode()) {
    echo 'Fault Code: ' . $resp_rt->faultCode() . "\n";
    echo 'Fault Reason: ' . $resp_rt->faultString() . "\n";
} else {
    $val_rt = $resp_rt->value();
    $blocks_rt = XML_RPC_decode($val_rt);
   
    // now we decode the results
   
    // Get the Agents' Status
    $agent = getAgentLoggedIn( "RealtimeDO.RTAgentsLoggedIn", $blocks_rt );
    // Get all the current call details
    $agentStatus = getCurrentCalls( "RealtimeDO.RTCallsBeingProc", $blocks_rt);   
    // Get details of all the queue activity and store them in the $queue array
    getQueueStatus( "RealtimeDO.RTRiassunto", $blocks_rt, $queueids, $print);   
    // Output the html for the $queue array
    printQueues($queue);
   
}
   

// Get the current queue stats and place them into the $queue array
function getQueueStatus( $blockname, $blocks, $queueids, $print ) {
    global $queue, $queuelist, $ragents;
     $block = $blocks[$blockname];
     for ( $r = 1; $r < sizeof( $block ) ; $r++ ) {
       $currentQueue = $block[$r][1];
       if ( $currentQueue == "all selected") {
         $ragents = $block[$r][3];
//         continue;
        }

        // if this is a SubQueue, we need to put all the results into the Master Queue for display
       if (1 == substr_count($currentQueue,'.')) {
         list($masterqueue, $subqueue) = explode('.', $currentQueue);
         
         $currentQueue = $masterqueue;
         $queue[$currentQueue]['name'] =  $masterqueue;
         $queue[$currentQueue]['waiting'] =  $block[$r][7] + $queue[$currentQueue]['waiting'];
         $queue[$currentQueue]['nagents'] = $block[$r][2];
         $queue[$currentQueue]['ragents'] = $block[$r][3];
         $queue[$currentQueue]['incalls'] = $block[$r][8] + $queue[$currentQueue]['incalls'];         
         $queue[$currentQueue]['outcalls'] = $block[$r][9] + $queue[$currentQueue]['outcalls'];
         
         
       } else { // it is a normal queue
         $queue[$currentQueue]['waiting'] =  $block[$r][7];
         $queue[$currentQueue]['name'] =  $block[$r][1];
         $queue[$currentQueue]['nagents'] = $block[$r][2];
         $queue[$currentQueue]['ragents'] = $block[$r][3];
         $queue[$currentQueue]['incalls'] = $block[$r][8];       
         $queue[$currentQueue]['outcalls'] = $block[$r][9];       
       }
       // sometimes the maxholdtime is blank, fix it
      if($queue[$currentQueue]['maxholdtime'] == '') $queue[$currentQueue]['maxholdtime'] = '00:00';
     
      // If this is an Outbound queue it needs some special treatment
      if (preg_match('/utbound/', $currentQueue)) {
        $ragents = $queue[$currentQueue]['ragents'];
        $queue[$currentQueue]['waiting'] = '0';
        $queue[$currentQueue]['maxholdtime'] = '00:00';
      }
    }

// This function sorts the $data array of arrays by $field
function orderBy(&$data, $field) {
  $code = "return strnatcmp(\$a['$field'], \$b['$field']);";
  usort($data, create_function('$a,$b', $code));
}

// create the html output for the $queues array
function printQueues($queues) {
  orderBy($queues,'name');
  global $ragents;
  $tdwidth = round(100/sizeof($queues),1) . "%";
  foreach ( $queues as $queue  ) {
    // width for the tables
    $currentQueue = $queue['name'];
    if (1 == substr_count($currentQueue,'Master')) continue;
    $queueholdtime = $queue['maxholdtime'];
    $waitqueue = $queue['waiting'];
    $nagents = $queue['nagents'];
    $currcalls = $queue['incalls'] + $queue['outcalls'];
    $ragents = $queue['ragents'];
     
    // Set up colour and formatting  depending on the status of the queue
    if( $waitqueue == 0 ) {
      $waitbgcolor = "green";
      $snd = null;
      $waitfontcolor = "white";
    } elseif ($waitqueue == 1){
      $waitbgcolor = "yellow";
      $snd = '<EMBED SRC="/sounds/dingdong.wav" HIDDEN="true" AUTOSTART="true">';
      $waitfontcolor = "black";
    } elseif ($waitqueue > 1) {
      $waitbgcolor = "red";
      $snd = '<EMBED SRC="/sounds/ringer.wav" HIDDEN="true" AUTOSTART="true">';
      $waitfontcolor = "white";
      $waitqueue = "<blink>" . $waitqueue . "</blink>";
    }

    if( $ragents > 2 ) {
      $ragentsbgcolor = "green";
      $ragentsfontcolor = "white";
    } elseif ($ragents == 2){
      $ragentsbgcolor = "yellow";
      $ragentsfontcolor = "black";
    } elseif ($ragents <= 1) {
      $ragentsbgcolor = "red";
      $ragentsfontcolor = "white";
    }


    print <<<END
    <td width="$tdwidth" valign="top">
   <div style="border: 2px solid #FFF; width: 100%">
        <div width="100%" align="center" valign="center" style="color:white; font-size: 15px; background-color: green; height: 20px;">$currentQueue</div>
        <div style="background-color: grey; height:3px">&nbsp;</div>
        <div align="center" style="color:$waitfontcolor; font-size: 15px; background-color: $waitbgcolor; ">Calls Waiting</div>
          <div align="center" style="color:$waitfontcolor; font-size: 70px; background-color: $waitbgcolor; ">$waitqueue</div>
        <div align="center" style="color:$waitfontcolor; font-size: 15px; background-color: $waitbgcolor; ">Max $queueholdtime</div>          
        <div style="background-color: grey; height:3px">&nbsp;</div>
        <div align="center" style="color:white; font-size: 15px; background-color: green">Curr Calls:</div>
        <div align="center" style="color:white; font-size: 70px;  background-color: green">$currcalls</div>
         <div style="background-color: grey; height:3px">&nbsp;</div>
          <div align="center" style="color:$ragentsfontcolor; font-size: 20px; background-color: $ragentsbgcolor">Rdy Agnt: $ragents/$nagents</div>
<!--        <div align="center" style="color:$ragentsfontcolor; font-size: 70px; background-color: $ragentsbgcolor">$ragents </div> -->

     </div>
      </td>
END;
    }
  }
}

// Get the actual status of each agent
function getAgentLoggedIn( $blockname, $blocks ) {
    $agent = array();
    $block = $blocks[$blockname];
     for ( $r = 1; $r < sizeof( $block ) ; $r++ ) {
       $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'] = 'none';
       $agent[$block[$r][1]]['entered'] = null;
       $agent[$block[$r][1]]['waiting'] = null;
       $agent[$block[$r][1]]['duration'] = null;
      }
    return $agent;

}

// Get the current call details for each agent or call waiting
function getCurrentCalls( $blockname, $blocks) {
    global $agent, $queue;
    $block = $blocks[$blockname];
     for ( $r = 1; $r < sizeof( $block ) ; $r++ ) {
       $agentname = $block[$r][6];
       $agent[$agentname]['queue'] = $block[$r][1];
       $agent[$agentname]['caller'] = $block[$r][2];
       $agent[$agentname]['entered'] = $block[$r][3];
       $agent[$agentname]['waiting'] = $block[$r][4];
       $agent[$agentname]['duration'] = $block[$r][5];
        if ($agent[$agentname]['duration'] == '-') {
          if (1 == substr_count($agent[$agentname]['queue'],'.')) {
            list($agent[$agentname]['queue'], $subqueue) = explode('.', $agent[$agentname]['queue']);
          }

          if (toSec($agent[$agentname]['waiting']) > toSec($queue[$agent[$agentname]['queue']]['maxholdtime'])) $queue[$agent[$agentname]['queue']]['maxholdtime'] = $agent[$agentname]['waiting'] ;
        }       
      }
      $agentStatus = '';
      $rowcount=1;
      for  ( $r = 0; $r < sizeof( $agent ) ; $r++ ) {
        $agent = array_values($agent);
        if ($rowcount == 1){
          $rowcolor = "green";
          $rowcount++;
        } elseif ($rowcount == 2) {
          $rowcolor = "gray";
          $rowcount = 1;
        }

        // get the last call time for the agent, and convery to epoc time
        if (strstr($agent[$r]['lastcall'],':')) {
          list($h, $m, $s) = explode(':', $agent[$r]['lastcall']);
          $lastcalltime = mktime($h,$m,$s);
        }
        // decide on the agent status we should display       
        if ($agent[$r]['duration'] != '') {
          $status = "On Call since " . $agent[$r]['entered'] . " (" . $agent[$r]['duration'] . " mins)";
          $bgcolor3 = $rowcolor;
          $fontcolor3 = "white";
        } elseif (!preg_match('/-/',$agent[$r]['onpause'])){
          $status = "On Pause since " . $agent[$r]['onpause'];
          $bgcolor3 = $rowcolor;
          $fontcolor3 = "white";
        } elseif (time() - $lastcalltime  < 5) {
          $status = "Wrapping up";
          $bgcolor3 = $rowcolor;
          $fontcolor3 = "white";
        } else {
          $status = "Available";
          $bgcolor3 = $rowcolor;
          $fontcolor3 = "white";
        }
        if ($agent[$r]['name']) {
          $agentStatus .="<tr bgcolor=\"" . $rowcolor . "\" style=\"color:white; font-size: 20px;\"><td>&nbsp;</td><td>" . $agent[$r]['name'] . "</td><td style=\"color:" . $fontcolor3 . ";\" bgcolor=\"" . $bgcolor3 . "\" >" . $status .  "</td><td>" . $agent[$r]['lastcall'] .  "</td><td>" . $agent[$r]['queue'] . "</td></tr>";
        }
      }
    return $agentStatus;
}

// function to convert 00:00:00 time to seconds.
function toSec ($hms) {
      list($h, $m, $s) = explode (":", $hms);
      $seconds = 0;
      $seconds += (intval($h) * 3600);
      $seconds += (intval($m) * 60);
      $seconds += (intval($s));
      return $seconds;
}


?>

</tr><tr><td>&nbsp;</td></tr><tr>
<!-- Agent Status Table -->
<td colspan=20 bgcolor="gray" valign="top">
<table  width="100%" height="100%" cellpadding=0 cellspacing=0 style="border: 2px solid #000">
  <tr style="color:white; font-size: 25px;">
    <td>&nbsp;</td><td>Agent</td><td>Status</td><td>Last Call</td><td>Current Queue</td>
  </tr>
  <?php echo $agentStatus ?>
</table>

</td>

</table>
</body>
</html>



QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Wallboard agent status with dynamic users.
« Reply #3 on: July 26, 2012, 10:19:13 »
I would start by tracing the dialogue between QM and the client, to see what is going wrong. The XML-RPC interface you use has not been changed in ages IIRC.

bren@nssl.ie

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Wallboard agent status with dynamic users.
« Reply #4 on: October 21, 2013, 19:24:28 »
Hi - Am have the same problem - Did you get an answer to problem with no agent details ?

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Wallboard agent status with dynamic users.
« Reply #5 on: October 22, 2013, 16:22:45 »
My impression is that the script accesses data out of absolute positions, and that is incorrect as they might change. We do not support such script though :(