1
QueueMetrics installation / Re: Agent Priority
« on: November 28, 2011, 21:10:41 »
We use leastrecent in our asterisk environment. It handles agent priorities and rings the agent who's been idle the longest.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
This sounds a bit like Frankenstein Jr. :-) but.... chapeau!
This sounds a bit like Frankenstein Jr. :-) but.... chapeau!
Do you mind if we add this to the Advanced Configuration manual? with proper credits, of course!
context queues-inbound{
XXXX =>{
Set(_CALLID=${UNIQUEID});
Set(_QUEUENAME=test);
Queue(test,t);
}
}
queues*CLI> queue show test
test has 0 calls (max unlimited) in 'leastrecent' strategy (3s holdtime, 96s talktime), W:0, C:12, A:4, SL:100.0% within 120s
Members:
local/1234@agents/n with penalty 1 (realtime) (Not in use) has taken no calls yet
context agents {
_. => {
Set(_AGENTTHATTRANSFERED=${EXTEN});
...
// doing a mysql database lookup to get Agents SIP Extension
...
Dial(SIP/${AGENT_EXTENSION});
}
}
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| id | time | callid | queuename | agent | event | data |
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| 1194627 | 1289929044 | 1289929028.30773 | test | NONE | ENTERQUEUE | |XXXXXXXXXX_1289929028.30773 |
| 1194629 | 1289929048 | 1289929028.30773 | test | local/1234@agents/n| CONNECT | 4|1289929045.30777|3 |
context agents-transferred {
_6. => {
NoOp("Current UniqueID: ${UNIQUEID}");
NoOp("inherited callid: ${CALLID}");
NoOp("inherited agendid: ${AGENTTHATTRANSFERED}");
NoOp("inherited queuename: ${QUEUENAME}");
MYSQL(Connect connid localhost UN PW asterisk_database);
if(${connid} = ""){
Playback(tt-error);
Hangup();
}else{
// make the query to track it
MYSQL(Query resultid ${connid} INSERT into transferred_calls(callid,full_extension) values('${CALLID}','${EXTEN}'));
// disconnect
MYSQL(Disconnect ${connid});
// now enter in our queue log
QueueLog(${QUEUENAME},${CALLID},local/${AGENTTHATTRANSFERED}@agents/n,TRANSFER,${EXTEN:1});
// dial the transferred extesion
Dial(SIP/${EXTEN:1});
};
if(${connid}){
MYSQL(Disconnect ${connid});
};
Hangup();
};
}
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| id | time | callid | queuename | agent | event | data |
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| 1194627 | 1289929044 | 1289929028.30773 | test | NONE | ENTERQUEUE | |XXXXXXXXXX_1289929028.30773 |
| 1194629 | 1289929048 | 1289929028.30773 | test | local/1234@agents/n| CONNECT | 4|1289929045.30777|3 |
| 1194642 | 1289929161 | 1289929028.30773 | test | local/1234@agents/n | TRANSFER | 299 |
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| id | time | callid | queuename | agent | event | data |
+---------+------------+------------------+-----------+-------------------+---------------+------------------------------+
| 1194627 | 1289929044 | 1289929028.30773 | test | NONE | ENTERQUEUE | |XXXXXXXXXX_1289929028.30773 |
| 1194629 | 1289929048 | 1289929028.30773 | test | local/1234@agents/n| CONNECT | 4|1289929045.30777|3 |
| 1194642 | 1289929161 | 1289929028.30773 | test | local/1234@agents/n | TRANSFER | 299 |
| 1194650 | 1289929253 | 1289929028.30773 | test | local/1234@agents/n | COMPLETEAGENT | 5|204|1 |
Is there any way to force or fake a TRANSFER record?
mysql> describe queue_member_table;
+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| uniqueid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| membername | varchar(40) | YES | | NULL | |
| queue_name | varchar(128) | YES | MUL | NULL | |
| interface | varchar(128) | YES | | NULL | |
| penalty | int(11) | YES | | NULL | |
| paused | int(11) | YES | | NULL | |
| state_interface | varchar(128) | YES | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)
+----------+--------------------+------------+--------------------+---------+--------+-----------------+
| uniqueid | membername | queue_name | interface | penalty | paused | state_interface |
+----------+--------------------+------------+--------------------+---------+--------+-----------------+
| 223008 | Agent/106 | TEST | local/106@agents/n | 1 | NULL | SIP/157 |
+----------+--------------------+------------+--------------------+---------+--------+-----------------+
mysql> describe queue_log;
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| time | char(10) | YES | | NULL | |
| callid | varchar(32) | NO | | | |
| queuename | varchar(32) | NO | | | |
| agent | varchar(32) | NO | | | |
| event | varchar(32) | NO | | | |
| data | varchar(255) | NO | | | |
+-----------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)
res_mysql.conf:
[general]
dbhost=127.0.0.1
dbname=ast_db
dbuser=asterisk
dbpass=XXXXXX
dbport=3306
sock=/var/run/mysqld/mysqld.sock
extconfig.conf:
[settings]
queue_log => mysql,general,queue_log
Really man, why not contribute the script to the sourceforge project?
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;
}
$agentStatus = getCurrentCalls( "RealtimeDO.RTCallsBeingProc", $blocks_rt, $agent );
And here is getCurrentCallsfunction 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;
}