Changed auto-alt-dial multi-lead processing to use server max recording time value for time in AST_VDauto_dial.pl script

Changed the AST_flush_DBqueue.pl script to only need to run from one server in a cluster
Fixed an issue on some systems with MANUAL dial method hotkey usage in vicidial.php
Changed non-agent-api agent stats export function to use case-insensitive user IDs and include all pauses
update docs
some small formatting changes and bug fixes

git-svn-id: svn://192.168.202.10@1803 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2012-04-04 17:38:42 +00:00
parent 2861501c5c
commit a4e8113ef4
8 changed files with 94 additions and 92 deletions
+4
View File
@@ -835,6 +835,10 @@ OTHER CHANGES:
for the call_log and vicidial_log_extended tables to be archived every
night and only keep the last 24-hours of logs in the active table.
193. Changed the AST_flush_DBqueue.pl script to only need to run on one server
NOTE: IMPORTANT !!!!! disable this script on the crontab of all but one
server on your cluster.
+22 -7
View File
@@ -107,6 +107,7 @@
# 110809-1516 - Added section for noanswer logging
# 110901-1125 - Added campaign areacode cid function
# 110922-1202 - Added logging of last calltime to campaign
# 120403-1839 - Changed auto-alt-dial multi-lead processing to use server max recording time value for time
#
@@ -226,7 +227,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs FROM servers where server_ip = '$server_ip';";
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs,vicidial_recording_limit FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -245,6 +246,7 @@ if ($sthArows > 0)
$DBSERVER_GMT = $aryA[9];
$DBext_context = $aryA[10];
$DBvd_server_logs = $aryA[11];
$DBvicidial_recording_limit = $aryA[12];
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
@@ -365,7 +367,7 @@ while($one_day_interval > 0)
$CPcount=0;
##### Get maximum calls per second that this process can send out
$stmtA = "SELECT outbound_calls_per_second FROM servers where server_ip='$server_ip';";
$stmtA = "SELECT outbound_calls_per_second,vicidial_recording_limit FROM servers where server_ip='$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -373,6 +375,7 @@ while($one_day_interval > 0)
{
@aryA = $sthA->fetchrow_array;
$outbound_calls_per_second = $aryA[0];
$DBvicidial_recording_limit = $aryA[1];
}
$sthA->finish();
@@ -2407,7 +2410,7 @@ while($one_day_interval > 0)
$MLincall='|INCALL|QUEUE|DISPO|';
$multi_alt_count=0;
$stmtA = "SELECT count(*) FROM vicidial_campaigns where auto_alt_dial='MULTI_LEAD' and dial_method NOT IN('MANUAL','INBOUND_MAN') and campaign_calldate > \"$RMSQLdate\";";
$stmtA = "SELECT count(*) FROM vicidial_campaigns where auto_alt_dial='MULTI_LEAD' and dial_method NOT IN('MANUAL','INBOUND_MAN') and campaign_calldate > \"$MCDSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -2424,7 +2427,7 @@ while($one_day_interval > 0)
@MLlists = @MT;
$MLcampaigns='|';
$stmtA = "SELECT campaign_id,auto_alt_dial_statuses FROM vicidial_campaigns where auto_alt_dial='MULTI_LEAD' and dial_method NOT IN('MANUAL','INBOUND_MAN') and campaign_calldate > \"$RMSQLdate\";";
$stmtA = "SELECT campaign_id,auto_alt_dial_statuses FROM vicidial_campaigns where auto_alt_dial='MULTI_LEAD' and dial_method NOT IN('MANUAL','INBOUND_MAN') and campaign_calldate > \"$MCDSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -2459,7 +2462,7 @@ while($one_day_interval > 0)
$MLcamp_count++;
}
$event_string = " MULTI_LEAD auto-alt-dial check: $multi_alt_count active, checking unprocessed calls...";
$event_string = " MULTI_LEAD auto-alt-dial check: $multi_alt_count active($MCDSQLdate), checking unprocessed calls...";
&event_logger;
@MLuniqueid = @MT;
@@ -2470,7 +2473,7 @@ while($one_day_interval > 0)
@MLcampaign = @MT;
@MLstatus = @MT;
$stmtA = "SELECT uniqueid,lead_id,call_date,caller_code FROM vicidial_log_extended where server_ip='$server_ip' and call_date > \"$RMSQLdate\" and multi_alt_processed='N' order by call_date,lead_id limit 100000;";
$stmtA = "SELECT uniqueid,lead_id,call_date,caller_code FROM vicidial_log_extended where server_ip='$server_ip' and call_date > \"$MCDSQLdate\" and multi_alt_processed='N' order by call_date,lead_id limit 100000;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -2514,7 +2517,7 @@ while($one_day_interval > 0)
if ($vac_count < 1)
{
$stmtA = "SELECT campaign_id,status FROM vicidial_log where uniqueid='$MLuniqueid[$vle_count]' and lead_id='$MLleadid[$vle_count]' and call_date > \"$RMSQLdate\";";
$stmtA = "SELECT campaign_id,status FROM vicidial_log where uniqueid='$MLuniqueid[$vle_count]' and lead_id='$MLleadid[$vle_count]' and call_date > \"$MCDSQLdate\";";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -3311,6 +3314,18 @@ sub get_time_now #get the current date and time and epoch for logging call lengt
$TDtsSQLdate = "$Tyear$Tmon$Tmday$Thour$Tmin$Tsec";
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$MCDtarget = ($secX - ($DBvicidial_recording_limit * 60));
($MCsec,$MCmin,$MChour,$MCmday,$MCmon,$MCyear,$MCwday,$MCyday,$MCisdst) = localtime($MCDtarget);
$MCyear = ($MCyear + 1900);
$MCmon++;
if ($MCmon < 10) {$MCmon = "0$MCmon";}
if ($MCmday < 10) {$MCmday = "0$MCmday";}
if ($MChour < 10) {$MChour = "0$MChour";}
if ($MCmin < 10) {$MCmin = "0$MCmin";}
if ($MCsec < 10) {$MCsec = "0$MCsec";}
$MCDtsSQLdate = "$MCyear$MCmon$MCmday$MChour$MCmin$MCsec";
$MCDSQLdate = "$MCyear-$MCmon-$MCmday $MChour:$MCmin:$MCsec";
$RMtarget = ($secX - 21600); # 6 hours ago
($RMsec,$RMmin,$RMhour,$RMmday,$RMmon,$RMyear,$RMwday,$RMyday,$RMisdst) = localtime($RMtarget);
$RMyear = ($RMyear + 1900);
+44 -73
View File
@@ -1,14 +1,15 @@
#!/usr/bin/perl
#
# AST_flush_DBqueue.pl version 2.2.0
# AST_flush_DBqueue.pl version 2.4
#
# DESCRIPTION:
# - clears out mysql records for this server for the ACQS vicidial_manager table
# - optimizes tables used frequently by VICIDIAL
# - OPTIMIZEs tables used frequently by VICIDIAL
#
# It is recommended that you run this program on the local Asterisk machine
# !!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!
# THIS SCRIPT SHOULD ONLY BE RUN ON ONE SERVER ON YOUR CLUSTER
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2012 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 60717-1214 - changed to DBI by Marin Blu
@@ -16,40 +17,41 @@
# 60910-0238 - removed park_log query
# 90628-2358 - Added vicidial_drop_rate_groups optimization
# 91206-2149 - Added vicidial_campaigns and vicidial_lists optimization
# 120404-1315 - Changed to run only on DB server<you should remove from other servers' crontabs>
#
$secX = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$SQLdate_NOW="$year-$mon-$mday $hour:$min:$sec";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()-3600);
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$SQLdate_NEG_1hour="$year-$mon-$mday $hour:$min:$sec";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time()-1800);
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$year = ($year + 1900);
$yy = $year; $yy =~ s/^..//gi;
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$SQLdate_NEG_halfhour="$year-$mon-$mday $hour:$min:$sec";
### begin parsing run-time options ###
@@ -148,14 +150,12 @@ $stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';"
$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)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBvd_server_logs = $aryA[0];
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
}
$sthA->finish();
@@ -164,13 +164,13 @@ if ($SYSLOG)
else
{$flush_time = $SQLdate_NEG_halfhour;}
$stmtA = "delete from vicidial_manager where server_ip='$server_ip' and entry_date < '$flush_time';";
$stmtA = "DELETE from vicidial_manager where entry_date < '$flush_time';";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - vicidial_manager flush\n";}
$stmtA = "optimize table vicidial_manager;";
$stmtA = "OPTIMIZE table vicidial_manager;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
@@ -181,10 +181,10 @@ if (!$T)
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_manager \n";}
if (!$Q) {print " - OPTIMIZE vicidial_manager \n";}
$stmtA = "optimize table vicidial_live_agents;";
$stmtA = "OPTIMIZE table vicidial_live_agents;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
@@ -195,25 +195,10 @@ if (!$T)
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_live_agents \n";}
if (!$Q) {print " - OPTIMIZE vicidial_live_agents \n";}
$stmtA = "optimize table vicidial_auto_calls;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$rec_countY++;
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_auto_calls \n";}
$stmtA = "optimize table vicidial_hopper;";
$stmtA = "OPTIMIZE table vicidial_drop_rate_groups;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
@@ -224,10 +209,10 @@ if (!$T)
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_hopper \n";}
if (!$Q) {print " - OPTIMIZE vicidial_drop_rate_groups \n";}
$stmtA = "optimize table vicidial_drop_rate_groups;";
$stmtA = "OPTIMIZE table vicidial_campaigns;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
@@ -238,10 +223,10 @@ if (!$T)
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_drop_rate_groups \n";}
if (!$Q) {print " - OPTIMIZE vicidial_campaigns \n";}
$stmtA = "optimize table vicidial_campaigns;";
$stmtA = "OPTIMIZE table vicidial_lists;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
@@ -252,21 +237,7 @@ if (!$T)
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_campaigns \n";}
$stmtA = "optimize table vicidial_lists;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
if (!$Q) {print " - optimize vicidial_lists \n";}
if (!$Q) {print " - OPTIMIZE vicidial_lists \n";}
+1
View File
@@ -442,6 +442,7 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
* * * * * /usr/share/astguiclient/AST_conf_update.pl
### flush queue DB table every hour for entries older than 1 hour
###### SHOULD ONLY BE RUN ON ONE SERVER IN A CLUSTER!!!!! #####
11 * * * * /usr/share/astguiclient/AST_flush_DBqueue.pl -q
### fix the vicidial_agent_log once every hour and the full day run at night
+2
View File
@@ -53,6 +53,7 @@ AS OF RELEASE 2.2.0 YOU SHOULD NOT HAVE TO TAKE ANY STEPS BEYOND STEP 2 IN THIS
- AST_VDauto_dial_FILL.pl (defined in /etc/astguiclient.conf)
- ADMIN_archive_log_tables.pl (crontab)
- AST_DB_dead_cb_purge.pl (crontab)
- AST_flush_DBqueue.pl (crontab)
2. The VARactive_keepalives variable in /etc/astguiclient.conf should have "5" and "7" on only ONE SERVER in your entire dialer setup, the other servers should not have 5 or 7 in that field.
@@ -191,6 +192,7 @@ If you have any questions or problems please post to the astguiclient-users list
- AST_VDadapt.pl (defined in /etc/astguiclient.conf)
- AST_VDauto_dial_FILL.pl (defined in /etc/astguiclient.conf)
- ADMIN_archive_log_tables.pl (crontab)
- AST_flush_DBqueue.pl (crontab)
8. On all servers but one you should DELETE the following line from your extensions.conf:
; prompt recording AGI script, ID is 4321
+1
View File
@@ -2421,6 +2421,7 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running
* * * * * /usr/share/astguiclient/AST_conf_update.pl
### flush queue DB table every hour for entries older than 1 hour
###### SHOULD ONLY BE RUN ON ONE SERVER IN A CLUSTER!!!!! #####
11 * * * * /usr/share/astguiclient/AST_flush_DBqueue.pl -q
### fix the vicidial_agent_log once every hour and the full day run at night
+18 -10
View File
@@ -376,10 +376,11 @@
# 120213-2029 - Changed consultative transfer with custom fields behavior for better data updating
# 120223-2119 - Removed logging of good login passwords if webroot writable is enabled
# 120308-1617 - Added compatibility for DAHDI phones using asterisk version for server > 1.4.21.2
# 120403-1204 - Fixed issue with MANUAL dial method hotkeys, added 1 second delay
#
$version = '2.4-343c';
$build = '120308-1617';
$version = '2.4-344c';
$build = '120403-1204';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=75;
$one_mysql_log=0;
@@ -8290,7 +8291,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
alt_dial_active = 0;
alt_dial_status_display = 0;
reselect_alt_dial = 0;
manual_auto_hotkey = 1;
manual_auto_hotkey = 2;
}
}
}
@@ -8301,7 +8302,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
alt_dial_active = 0;
alt_dial_status_display = 0;
manual_auto_hotkey = 1;
manual_auto_hotkey = 2;
}
else
{
@@ -8329,7 +8330,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
{
if (hotkeysused == 'YES')
{
manual_auto_hotkey = 1;
manual_auto_hotkey = 2;
alt_dial_active=0;
alt_dial_status_display = 0;
@@ -9170,11 +9171,11 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
else
{
// trigger HotKeys manual dial automatically go to next lead
if (manual_auto_hotkey == '1')
{
manual_auto_hotkey = 0;
ManualDialNext('','','','','','0');
}
// if (manual_auto_hotkey > 0)
// {
// manual_auto_hotkey = 0;
// ManualDialNext('','','','','','0');
// }
}
}
}
@@ -11994,6 +11995,13 @@ function phone_number_format(formatphone) {
if ( (custchannellive < -10) && (lastcustchannel.length > 3) ) {ReChecKCustoMerChaN();}
if ( (nochannelinsession > 16) && (check_n > 15) && (no_empty_session_warnings < 1) ) {NoneInSession();}
if (external_transferconf_count > 0) {external_transferconf_count = (external_transferconf_count - 1);}
if (manual_auto_hotkey == "1")
{
manual_auto_hotkey = 0;
ManualDialNext('','','','','','0');
}
if (manual_auto_hotkey > 1) {manual_auto_hotkey = (manual_auto_hotkey - 1);}
if (WaitingForNextStep==0)
{
if (trigger_ready > 0)
+2 -2
View File
@@ -3533,7 +3533,7 @@ if ($function == 'agent_stats_export')
{
# user,lead_id,sub_status,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec
$row=mysql_fetch_row($rslt);
if ($last_user != $row[0])
if (!preg_match("/^$last_user$/i", $row[0]))
{
$uc++;
$ASuser[$uc] = $row[0];
@@ -3548,7 +3548,7 @@ if ($function == 'agent_stats_export')
$AScalls[$uc]++;
$total_calls++;
}
if ($row[3] > 0)
if ($row[3] > -1)
{
$ASpauses[$uc]++;
}