From 3b5f770743c8a92f96cc81384414cdc65b103998 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 27 Sep 2013 20:20:42 +0000 Subject: [PATCH] Changes to queue_log IVR event logging for new QM features git-svn-id: svn://192.168.202.10@2028 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/agi-DID_route.agi | 13 +++ agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi | 125 +++++++++++++++------ agc_2-X/trunk/agi/cm.agi | 63 ++++++----- 3 files changed, 138 insertions(+), 63 deletions(-) diff --git a/agc_2-X/trunk/agi/agi-DID_route.agi b/agc_2-X/trunk/agi/agi-DID_route.agi index c74a7f8c..47b3e924 100644 --- a/agc_2-X/trunk/agi/agi-DID_route.agi +++ b/agc_2-X/trunk/agi/agi-DID_route.agi @@ -31,6 +31,7 @@ # 120430-2214 - Converted call to Monitor app to be asterisk 1.8 compatible # 130108-1810 - Changes for Asterisk 1.8 compatibility # 130925-1819 - Added variable filter to prevent DID SQL injection attack +# 130926-1549 - Added new queue_log IVR entries for QM # $script = 'agi-DID_route.agi'; @@ -621,6 +622,18 @@ if ($did_route =~ /EXTEN/) ### Route call to a call menu on the system if ($did_route =~ /CALLMENU/) { + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$uniqueid',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$callerid',data3='$extension',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhB->disconnect(); + } + $XFERcontext = "$menu_id"; if ($AGILOG) {$agi_string = "exiting the DID app, transferring call to CALLMENU $XFERcontext"; &agi_output;} print "SET CONTEXT $XFERcontext\n"; diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi index 623aab1f..b61433d9 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi @@ -185,6 +185,7 @@ # 121129-1618 - Small fix for estimated hold time, excluding QUEUE status # 130108-1804 - Changes for Asterisk 1.8 compatibility # 130925-1821 - Added variable filter to prevent DID SQL injection attack +# 130926-1548 - Added new queue_log IVR entries for QM # $script = 'agi-VDAD_ALL_inbound.agi'; @@ -310,6 +311,37 @@ while ($sthArows > $rec_count) } $sthA->finish(); +############################################# +##### START SYSTEM SETTINGS LOOKUP ##### +$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_eq_prepend,queuemetrics_pe_phone_append,did_agent_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_ra_extensions_enabled,queuemetrics_socket,queuemetrics_socket_url FROM system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02026'; $MEL_aff_rows=$sthArows; &mysql_error_logging; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = $aryA[0]; + $queuemetrics_server_ip = $aryA[1]; + $queuemetrics_dbname = $aryA[2]; + $queuemetrics_login= $aryA[3]; + $queuemetrics_pass = $aryA[4]; + $queuemetrics_log_id = $aryA[5]; + $queuemetrics_eq_prepend = $aryA[6]; + $queuemetrics_pe_phone_append = $aryA[7]; + $did_agent_log = $aryA[8]; + $alt_log_server_ip = $aryA[9]; + $alt_log_dbname = $aryA[10]; + $alt_log_login = $aryA[11]; + $alt_log_pass = $aryA[12]; + $tables_use_alt_log_db = $aryA[13]; + $did_ra_extensions_enabled = $aryA[14]; + $queuemetrics_socket = $aryA[15]; + $queuemetrics_socket_url = $aryA[16]; + } +$sthA->finish(); +##### END SYSTEM SETTINGS LOOKUP ##### +########################################### ### begin parsing run-time options ### if (length($ARGV[0])>1) @@ -1397,6 +1429,18 @@ if ( ( ( ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) && ($hm >= $c if ($AGILOG) {$agi_string = "callerID changed: $newcallerid"; &agi_output;} $DROPexten = 's'; $ext_context = $after_hours_callmenu; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$uniqueid',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$phone_number',data3='$channel_group',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; + } } if ($after_hours_action =~ /EXTENSION/) { @@ -1654,6 +1698,18 @@ if ( ( ($no_agent_no_queue =~ /Y|NO_PAUSED/) || ($MCnanque_override > 0) ) && ($ if ($AGILOG) {$agi_string = "callerID changed: $newcallerid"; &agi_output;} $DROPexten = 's'; $ext_context = $no_agent_action_value; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$uniqueid',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$phone_number',data3='$channel_group',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; + } } if ($no_agent_action =~ /VOICEMAIL/) { @@ -1846,37 +1902,6 @@ if ($call_handle_method =~ /CLOSER|DIGITID$/) if ($AGILOG) {$agi_string = "-- VDXL : |$insert_lead_id|$insert_xfer_id|insert to vicidial_xfer_log"; &agi_output;} } -############################################# -##### START SYSTEM SETTINGS LOOKUP ##### -$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_eq_prepend,queuemetrics_pe_phone_append,did_agent_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_ra_extensions_enabled,queuemetrics_socket,queuemetrics_socket_url FROM system_settings;"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02026'; $MEL_aff_rows=$sthArows; &mysql_error_logging; -if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $enable_queuemetrics_logging = $aryA[0]; - $queuemetrics_server_ip = $aryA[1]; - $queuemetrics_dbname = $aryA[2]; - $queuemetrics_login= $aryA[3]; - $queuemetrics_pass = $aryA[4]; - $queuemetrics_log_id = $aryA[5]; - $queuemetrics_eq_prepend = $aryA[6]; - $queuemetrics_pe_phone_append = $aryA[7]; - $did_agent_log = $aryA[8]; - $alt_log_server_ip = $aryA[9]; - $alt_log_dbname = $aryA[10]; - $alt_log_login = $aryA[11]; - $alt_log_pass = $aryA[12]; - $tables_use_alt_log_db = $aryA[13]; - $did_ra_extensions_enabled = $aryA[14]; - $queuemetrics_socket = $aryA[15]; - $queuemetrics_socket_url = $aryA[16]; - } -$sthA->finish(); -##### END SYSTEM SETTINGS LOOKUP ##### -########################################### if ($enable_queuemetrics_logging > 0) { $data2 = "$phone_number"; @@ -1960,7 +1985,7 @@ if ($Uaffected_rows < 1) if ($enable_queuemetrics_logging > 0) { $QL_last_day = ($now_date_epoch - 86400); - $stmtB = "UPDATE queue_log SET call_id='$YqueryCID' where time_id > '$QL_last_day' and call_id='$uniqueid' and queue='NONE' and agent='NONE' and verb='INFO' and data1 IN('DID','IVR');"; + $stmtB = "UPDATE queue_log SET call_id='$YqueryCID' where time_id > '$QL_last_day' and call_id='$uniqueid' and queue='NONE' and agent='NONE' and verb='INFO' and data1 IN('DID','IVR','IVRAPPEND','IVRSTART','IVRGOAL');"; $Baffected_rows = $dbhB->do($stmtB); if ($AGILOG) {$agi_string = "$Baffected_rows|$stmtB|"; &agi_output;} $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02115'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; @@ -4009,6 +4034,18 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override { $DROPexten = "s"; $ext_context = "$wait_time_option_callmenu"; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$phone_number',data3='$channel_group',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; + } } } if ($wait_time_option =~ /IN_GROUP/) @@ -4422,6 +4459,18 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override { $DROPexten = "s"; $ext_context = "$hold_time_option_callmenu"; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$phone_number',data3='$channel_group',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; + } } } if ($hold_time_option =~ /IN_GROUP/) @@ -4817,6 +4866,18 @@ if ( ($drop_timer > $DROP_TIME) || ($MCdrop_override > 0) ) if ($AGILOG) {$agi_string = "callerID changed: $newcallerid"; &agi_output;} $DROPexten = 's'; $ext_context = $drop_callmenu; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QM DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='NONE',agent='NONE',verb='INFO',data1='IVRSTART',data2='$phone_number',data3='$channel_group',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + $dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='02XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging; + } } if ($drop_action =~ /IN_GROUP/) { # 90009*CL_uk3survy_*8301*10000123*universal*7275551212*1234*" diff --git a/agc_2-X/trunk/agi/cm.agi b/agc_2-X/trunk/agi/cm.agi index c769b3d7..658ef2f8 100644 --- a/agc_2-X/trunk/agi/cm.agi +++ b/agc_2-X/trunk/agi/cm.agi @@ -26,6 +26,7 @@ # 111003-2150 - Added field to update # 120730-0729 - Changed to allow inbound logging when lead is defined # 130925-1822 - Added variable filter to prevent DID SQL injection attack +# 130926-1547 - Added new queue_log IVR entries for QM # $script = 'cm.agi'; @@ -113,22 +114,22 @@ $sthA->finish(); ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### -#$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_eq_prepend FROM system_settings;"; -#$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -#$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -#$sthArows=$sthA->rows; -#if ($sthArows > 0) -# { -# @aryA = $sthA->fetchrow_array; -# $enable_queuemetrics_logging = $aryA[0]; -# $queuemetrics_server_ip = $aryA[1]; -# $queuemetrics_dbname = $aryA[2]; -# $queuemetrics_login= $aryA[3]; -# $queuemetrics_pass = $aryA[4]; -# $queuemetrics_log_id = $aryA[5]; -# $queuemetrics_eq_prepend = $aryA[6]; -# } -#$sthA->finish(); +$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_eq_prepend FROM system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = $aryA[0]; + $queuemetrics_server_ip = $aryA[1]; + $queuemetrics_dbname = $aryA[2]; + $queuemetrics_login= $aryA[3]; + $queuemetrics_pass = $aryA[4]; + $queuemetrics_log_id = $aryA[5]; + $queuemetrics_eq_prepend = $aryA[6]; + } +$sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### ########################################### @@ -305,21 +306,21 @@ else } ### QueueMetrics logging if enabled -#if ($enable_queuemetrics_logging > 0) -# { -# $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") -# or die "Couldn't connect to database: " . DBI->errstr; -# -# if ($DBX) {print "CONNECTED TO QueueMetrics DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} -# -# if ($outboundIVR > 0) -# {$uniqueid = $caller_id;} -# -# $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$uniqueid',queue='NONE',agent='NONE',verb='INFO',data1='IVR',data2='$context',serverid='$queuemetrics_log_id';"; -# if ($AGILOG) {$agi_string = "|$stmtB|"; &agi_output;} -# $Baffected_rows = $dbhB->do($stmtB); -# $dbhB->disconnect(); -# } +if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO QueueMetrics DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + if ($outboundIVR > 0) + {$uniqueid = $caller_id;} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$uniqueid',queue='NONE',agent='NONE',verb='INFO',data1='IVRAPPEND',data2='$dtmf',data3='$context',serverid='$queuemetrics_log_id';"; + if ($AGILOG) {$agi_string = "|$stmtB|"; &agi_output;} + $Baffected_rows = $dbhB->do($stmtB); + $dbhB->disconnect(); + } $sthA->finish();