From 1ff603b75ffa00a2b091c354882c23e5b51059f5 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 14 Feb 2007 20:15:16 +0000 Subject: [PATCH] added ENTERQUEUE/CONNECT/EXITWITHTIMEOUT queue_log entries to agi-VDADtransfer.agi git-svn-id: svn://192.168.202.10@524 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/agi-VDADtransfer.agi | 74 ++++++++++++++++++++++++++ agc_2-X/trunk/docs/QUEUEMETRICS.txt | 17 ++++-- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/agc_2-X/trunk/agi/agi-VDADtransfer.agi b/agc_2-X/trunk/agi/agi-VDADtransfer.agi index 5ad64d18..2172de9a 100644 --- a/agc_2-X/trunk/agi/agi-VDADtransfer.agi +++ b/agc_2-X/trunk/agi/agi-VDADtransfer.agi @@ -256,6 +256,7 @@ exit; } + ### Grab call parameters from vicidial_auto_calls table $stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE',stage='LIVE-0' where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); @@ -304,6 +305,53 @@ if ($affected_rows > 0) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDAD : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid"; &agi_output;} + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @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]"; + $rec_count++; + } + $sthA->finish(); + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $stmtA = "SELECT phone_number FROM vicidial_auto_calls where lead_id='$CIDlead_id';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $phone_number = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + + $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 DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='ENTERQUEUE',data2='$phone_number',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } } $drop_timer=0; @@ -413,6 +461,19 @@ if ($rec_countWAIT < $DBconcurrent_transfers) $dbhA->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 DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$callerid',queue='$VDADcampaign',agent='Agent/$VDADuser',verb='CONNECT',data1='$drop_timer',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + if ($AGILOG) {$agi_string = "exiting the VDAD app, transferring call to $VDADconf_exten"; &agi_output;} print "SET CONTEXT $ext_context\n"; checkresult($result); @@ -491,6 +552,19 @@ if ($drop_seconds < 1) { $drop_seconds = $DROP_TIME; + 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 DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='EXITWITHTIMEOUT',data1='1',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + if ($safe_harbor_message =~ /Y/) { $DROPexten = "$safe_harbor_exten"; diff --git a/agc_2-X/trunk/docs/QUEUEMETRICS.txt b/agc_2-X/trunk/docs/QUEUEMETRICS.txt index ceb9b5cf..38182482 100644 --- a/agc_2-X/trunk/docs/QUEUEMETRICS.txt +++ b/agc_2-X/trunk/docs/QUEUEMETRICS.txt @@ -6,6 +6,8 @@ QueueMetrics is a closed-source, commercial product written by Loway Research in This feature was added to the package at the request of several users of VICIDIAL and was achieved with some help from the makers of QueueMetrics(although all VICIDIAL code changes were done entirely by Matt Florell). +This feature is currently only functional on outbound dialing. + Here is a short summary of the needed steps to install QueueMetrics on your system: @@ -109,15 +111,18 @@ partition: set to "P01" for the first partition, should match up with configurat time_id: epoch, unixtime (seconds since 1970-01-01 00:00:00) [1170345603] call_id: Asterisk unique prepended with server_id field [1-1170345497.30369] + For VICIDIAL we will use the CallerIDname of the call to queue: the queue that call came into (we will use the campaign_id here) agent: we will use the user ID prepended by "agent/" [agent/6666] verbs: -system actions + +system actions - used by the AST_VDadapt.pl script when starting up QUEUESTART -agent actions + +agent actions - used by vicidial.php, vdc_db_query.php and AST_VDremote_agents.pl AGENTLOGIN(channel) AGENTLOGOFF(channel|logintime) PAUSEALL @@ -125,7 +130,8 @@ agent actions UNPAUSEALL UNPAUSE PAUSEREASON -call actions + +call actions - used by ENTERQUEUE(url|callerid) ABANDON(position|origposition|waittime) CONNECT(holdtime) @@ -144,7 +150,7 @@ data3: ?? data4: ?? -serverid: number of the server the call came from [1] +serverid: number of the server the call came from [for VICIDIAL use the system_settings.queuemetrics_log_id field] @@ -155,4 +161,5 @@ queuemetrics_server_ip VARCHAR(15), queuemetrics_dbname VARCHAR(50), queuemetrics_login VARCHAR(50), queuemetrics_pass VARCHAR(50), -queuemetrics_url VARCHAR(255) +queuemetrics_url VARCHAR(255), +queuemetrics_log_id VARCHAR(10) default 'VIC'