From 4eb6b57a37aba7958e03c2eb7d0121549487d85d Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 30 May 2009 14:13:26 +0000 Subject: [PATCH] Added live monitoring option through QueueMetrics feature git-svn-id: svn://192.168.202.10@1132 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 5 + docs/QUEUEMETRICS.txt | 9 +- www/vicidial/QM_live_monitor.php | 177 ++++++++++++++++++ www/vicidial/non_agent_api.php | 38 ++-- .../xml_rpc_audio_server_vicidial.php | 102 ++++++++-- 5 files changed, 301 insertions(+), 30 deletions(-) create mode 100644 www/vicidial/QM_live_monitor.php diff --git a/UPGRADE b/UPGRADE index e2314aff..70f773f8 100644 --- a/UPGRADE +++ b/UPGRADE @@ -62,6 +62,11 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 14. Added option to login as an agent with no phone. Must create a phones entry called nophone with dialplan number of 8300. +15. Added live monitoring of calls and retrieval of recorded calls through the + QueueMetrics interface + + + diff --git a/docs/QUEUEMETRICS.txt b/docs/QUEUEMETRICS.txt index 7ccb946c..6a013c61 100644 --- a/docs/QUEUEMETRICS.txt +++ b/docs/QUEUEMETRICS.txt @@ -4,18 +4,21 @@ queue_log logging was added to VICIDIAL outbound auto calling as an option in th This document goes over the features and needed changes made to VICIDIAL to enable it to insert activity records into the queue_log and other tables in MySQL that QueueMetrics uses for it's statistical analysis and reports. This document should not be taken as a HOWTO for proper installation steps to get QueueMetrics working. -QueueMetrics is a closed-source, commercial product written by Loway Research in Italy. The writers of VICIDIAL do not support or warranty QueueMetrics or it's functionality with VICIDIAL in any way. +QueueMetrics is a closed-source, commercial product written by Loway Research in Italy/Switzerland. The writers of VICIDIAL do not support or warranty QueueMetrics or it's functionality with VICIDIAL in any way. This feature was added to the package at the request of several users of VICIDIAL and was achieved with some help from the creators of QueueMetrics(although all VICIDIAL code changes were done entirely by Matt Florell). This feature is functional on outbound manual dialing, auto dialing and inbound call handling as of 2008-06-30(SVN trunk 2.0.5). -as of 2008-10-30, several validation and correction functions were added to the AST_cleanup_agent_log.pl script that is supposed to run every hour. These functions should clean up any queue_log errors that appear and cause QueueMetrics to display incorrect call totals. - Another very important issue to note is that just like with VICIDIAL on multi-server systems, if QueueMetrics data is being generated on a multi-server system the data will be corrupted if all of the servers are not on the same time. I strongly recommend getting ntp working properly on all servers in a VICIDIAL or QueueMetrics server cluster. To be able to view stats for inbound and outbound calls properly you need to add each one individually in QueueMetrics "queues" and properly set whether each one is inbound or outbound. After that you can create a combined queue-alias with all of the campaigns and in-groups in it and it will tell you correctly the number of inbound and outbound calls. +As of 2008-10-30, several validation and correction functions were added to the AST_cleanup_agent_log.pl script that is supposed to run every hour. These functions should clean up any queue_log errors that appear and cause QueueMetrics to display incorrect call totals. + +As of 2009-05-30, live montoring and playback of archived recordings through the QueueMetrics interface was added. To use this you must have the audio.server, audio.liveserver and default.audioRpcServer variables set properly in the configuration.properties file as specified toward the bottom of this document. The live monitoring asks for an extension to send the call to, this is an extension dialed on the active voicemail server as defined in the system settings. If there is no active voicemail defined then the live monitor will place the call to the extension on the server that the agent is on. + + Here is a short summary of the needed steps to install QueueMetrics on your system: diff --git a/www/vicidial/QM_live_monitor.php b/www/vicidial/QM_live_monitor.php new file mode 100644 index 00000000..71d1d53a --- /dev/null +++ b/www/vicidial/QM_live_monitor.php @@ -0,0 +1,177 @@ + LICENSE: AGPLv2 +# +# Script to initiate live monitoring from QueueMetrics link +# +# CHANGELOG: +# 90529-2115 - First Build +# + +$version = '2.2.0-1'; +$build = '90529-2115'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); +require("functions.php"); + + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session"])) {$session=$_GET["session"];} + elseif (isset($_POST["session"])) {$session=$_POST["session"];} +if (isset($_GET["phone"])) {$phone=$_GET["phone"];} + elseif (isset($_POST["phone"])) {$phone=$_POST["phone"];} +if (isset($_GET["type"])) {$type=$_GET["type"];} + elseif (isset($_POST["type"])) {$type=$_POST["type"];} +if (isset($_GET["call"])) {$call=$_GET["call"];} + elseif (isset($_POST["call"])) {$call=$_POST["call"];} +if (isset($_GET["QMuser"])) {$QMuser=$_GET["QMuser"];} + elseif (isset($_POST["QMuser"])) {$QMuser=$_POST["QMuser"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} + + +$ERR=0; +$ERRstring=''; + +############################################# +##### START QUEUEMETRICS LOGGING LOOKUP ##### +$stmt = "SELECT enable_queuemetrics_logging FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + } +##### END QUEUEMETRICS LOGGING LOOKUP ##### +########################################### +if ($enable_queuemetrics_logging > 0) + { + $stmt = "SELECT user,server_ip,conf_exten,comments FROM vicidial_live_agents where callerid='$call';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vla_conf_ct = mysql_num_rows($rslt); + if ($vla_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLAuser = $row[0]; + $VLAserver_ip = $row[1]; + $VLAconf_exten = $row[2]; + + $stmt = "SELECT campaign_id,phone_number,call_type FROM vicidial_auto_calls where callerid='$call';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vla_conf_ct = mysql_num_rows($rslt); + if ($vla_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VACcampaign = $row[0]; + $VACphone = $row[1]; + $VACtype = $row[2]; + + if ($stage == 'MONITOR') + { + $script_name = getenv("SCRIPT_NAME"); + $server_name = getenv("SERVER_NAME"); + $server_port = getenv("SERVER_PORT"); + if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} + $admDIR = "$HTTPprotocol$server_name$script_name"; + $admDIR = eregi_replace('QM_live_monitor.php','',$admDIR); + $monitor_script = 'non_agent_api.php'; + + $monitorURL = "$admDIR$monitor_script?source=queuemetrics&function=blind_monitor&user=$user&pass=$call&phone_login=$extension&session_id=$session&server_ip=$server_ip&stage=$stage"; + $monitorCONTENTS = file("$monitorURL"); + + if (eregi('SUCCESS',$monitorCONTENTS[0])) + { + echo "\n"; + } + else + { + echo "\n"; + echo "$monitorCONTENTS[0]
\n"; + } + + echo "\n"; + echo "\n"; + echo "
\n"; + echo ""; + echo "\n"; + echo "
\n"; + echo "\n"; + + exit; + } + else + { + echo ""; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Remote Monitor:
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + exit; + } + } + else + { + $ERR++; + $ERRstring = "Call not found"; + } + } + else + { + $ERR++; + $ERRstring = "Agent not found"; + } + } +else + { + $ERR++; + $ERRstring = "QueueMetrics is not enabled on this system"; + } + +if ($ERR > 0) + { + echo "ERROR: $ERRstring\n"; + echo "\n"; + echo "\n"; + exit; + } + +exit; + + + + diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 50df9636..659a2b35 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -23,10 +23,11 @@ # 90508-0642 - Changed to PHP long tags # 90514-0602 - Added sounds_list function # 90522-0506 - Security fix +# 90530-0946 - Added QueueMetrics blind monitoring option # -$version = '2.2.0-9'; -$build = '90522-0506'; +$version = '2.2.0-10'; +$build = '90530-0946'; require("dbconnect.php"); @@ -456,7 +457,7 @@ if ($function == 'blind_monitor') $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $allowed_user=$row[0]; - if ($allowed_user < 1) + if ( ($allowed_user < 1) and ($source != 'queuemetrics') ) { $result = 'ERROR'; $result_reason = "blind_monitor USER DOES NOT HAVE PERMISSION TO BLIND MONITOR"; @@ -490,7 +491,7 @@ if ($function == 'blind_monitor') $row=mysql_fetch_row($rslt); $phone_exists=$row[0]; - if ($phone_exists < 1) + if ( ($phone_exists < 1) and ($source != 'queuemetrics') ) { $result = 'ERROR'; $result_reason = "blind_monitor INVALID PHONE LOGIN"; @@ -501,13 +502,28 @@ if ($function == 'blind_monitor') } else { - $stmt="SELECT dialplan_number,server_ip,outbound_cid from phones where login='$phone_login';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $dialplan_number = $row[0]; - $monitor_server_ip =$row[1]; - $outbound_cid = $row[2]; + if ($source == 'queuemetrics') + { + $stmt="SELECT active_voicemail_server from system_settings;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $monitor_server_ip = $row[0]; + $dialplan_number = $phone_login; + $outbound_cid = ''; + if (strlen($monitor_server_ip)<7) + {$monitor_server_ip = $server_ip;} + } + else + { + $stmt="SELECT dialplan_number,server_ip,outbound_cid from phones where login='$phone_login';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $dialplan_number = $row[0]; + $monitor_server_ip =$row[1]; + $outbound_cid = $row[2]; + } $S='*'; $D_s_ip = explode('.', $server_ip); diff --git a/www/vicidial/xml_rpc_audio_server_vicidial.php b/www/vicidial/xml_rpc_audio_server_vicidial.php index f2d296ea..252985ac 100644 --- a/www/vicidial/xml_rpc_audio_server_vicidial.php +++ b/www/vicidial/xml_rpc_audio_server_vicidial.php @@ -8,6 +8,7 @@ # # CHANGES # 90525-1141 - First build +# 90529-2041 - Added Realtime monitoring # // $Id: xmlrpc_audio_server.php,v 1.3 2007/11/12 17:53:09 lenz Exp $ @@ -157,7 +158,6 @@ function find_file( $ServerID, $AsteriskID, $QMUserID, $QMUserName ) $FILE_ENCODING = "wav"; $FILE_DURATION = "0:00"; } - } else { @@ -177,17 +177,83 @@ function find_file( $ServerID, $AsteriskID, $QMUserID, $QMUserName ) # $FILE_DURATION = "1:12"; } -function listen_call( $ServerID, $AsteriskID, $Agent, $QMUserID, $QMUserName, $Direction ) +function listen_call( $ServerID, $AsteriskID, $Agent, $QMUserID, $QMUserName ) { global $CALL_FOUND; global $CALL_LISTEN_URL; global $CALL_POPUP_WIDTH; global $CALL_POPUP_HEIGHT; - $CALL_FOUND = false; - $CALL_LISTEN_URL = "http://listennow.server/$ServerID/$AsteriskID/$QMUserID/$QMUserName/$Agent/$Direction"; - $CALL_POPUP_WIDTH = "200"; + require("dbconnect.php"); + require("functions.php"); + + $CALL_POPUP_WIDTH = "250"; $CALL_POPUP_HEIGHT = "250"; + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $stmt = "SELECT user,server_ip,conf_exten,comments FROM vicidial_live_agents where callerid='$AsteriskID';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vla_conf_ct = mysql_num_rows($rslt); + if ($vla_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLAuser = $row[0]; + $VLAserver_ip = $row[1]; + $VLAconf_exten = $row[2]; + + $stmt = "SELECT campaign_id,phone_number,call_type FROM vicidial_auto_calls where callerid='$AsteriskID';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $vla_conf_ct = mysql_num_rows($rslt); + if ($vla_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VACcampaign = $row[0]; + $VACphone = $row[1]; + $VACtype = $row[2]; + + $script_name = getenv("SCRIPT_NAME"); + $server_name = getenv("SERVER_NAME"); + $server_port = getenv("SERVER_PORT"); + if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} + $admDIR = "$HTTPprotocol$server_name$script_name"; + $admDIR = eregi_replace('xml_rpc_audio_server_vicidial.php','',$admDIR); + $monitor_script = 'QM_live_monitor.php'; + + $CALL_FOUND = true; + $CALL_LISTEN_URL = "$admDIR$monitor_script?campaign=$VACcampaign&user=$VLAuser&server_ip=$VLAserver_ip&session=$VLAconf_exten&phone=$VACphone&type=$VACtype&call=$AsteriskID&QMuser=$QMUserID"; + } + else + { + $CALL_FOUND = false; + $CALL_LISTEN_URL = ""; + } + } + else + { + $CALL_FOUND = false; + $CALL_LISTEN_URL = ""; + } + } + +# $CALL_FOUND = true; +# $CALL_LISTEN_URL = "http://listennow.server/$ServerID/$AsteriskID/$QMUserID/$QMUserName/$Agent"; } @@ -220,16 +286,20 @@ function xmlrpc_find_file( $params ) { return new XML_RPC_Response($response); } -function xmlrpc_listen_call_inbound( $params ) { - xmlrpc_listen_call( $params, "INBOUND" ); -} - -function xmlrpc_listen_call_outbound( $params ) { - xmlrpc_listen_call( $params, "OUTBOUND" ); -} -function xmlrpc_listen_call( $params, $direction ) { + + + + + + + + + + + +function xmlrpc_listen_call( $params ) { global $CALL_FOUND; global $CALL_LISTEN_URL; global $CALL_POPUP_WIDTH; @@ -241,7 +311,7 @@ function xmlrpc_listen_call( $params, $direction ) { $p3 = $params->getParam(3)->scalarval(); // QM user ID $p4 = $params->getParam(3)->scalarval(); // QM user name - listen_call( $p0, $p1, $p2, $p3, $p4, $direction ); + listen_call( $p0, $p1, $p2, $p3, $p4 ); $response = new XML_RPC_Value(array( new XML_RPC_Value( $CALL_FOUND, 'boolean' ), @@ -264,10 +334,10 @@ $server = new XML_RPC_Server( 'function' => 'xmlrpc_find_file' ), 'QMAudio.listenOngoingCall' => array( - 'function' => 'xmlrpc_listen_call_inbound' + 'function' => 'xmlrpc_listen_call' ), 'QMAudio.listenOngoingCallOutbound' => array( - 'function' => 'xmlrpc_listen_call_outbound' + 'function' => 'xmlrpc_listen_call' ), ),
Agent: $user
Customer: $phone
Call Type: $type
Queue: $campaign
Extension:
"; + echo "