Added auto-kill to adapt script to facilitate cleaner clearing of daily stats

Added QM ABANDON call clearing in queue_log to agent log cleanup script
Fixed bug in conf_exten_check.php

git-svn-id: svn://192.168.202.10@1260 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2009-11-15 15:26:06 +00:00
parent 9a81ee5844
commit b471e8df0c
8 changed files with 197 additions and 28 deletions
+6
View File
@@ -267,6 +267,12 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom
a DNC list entry. Enabled by using the AREACODE option in Campaign
Detail settings
66. Added agi-NVA_recording.agi script to allow for recording of non-agent calls
as well as the ability to log them. If audio recording using this script
make sure you use the STEP 1 audio mixing script in your crontab with
the "--MIX" option so that these recordings are stored properly
+31 -3
View File
@@ -31,6 +31,7 @@
# 90415-0925 - Fixed rare division by zero bug
# 90512-1549 - Formatting fixes and calculation bugs in blended
# 90628-2001 - Added drop rate group functions
# 91115-0929 - Added auto-kill of script at timeclock reset time of day to facilitate cleaner clearing of daily stats
#
# constants
@@ -87,7 +88,6 @@ $VCSagents_active[$i]=0;
$drop_count_updater=61;
$secT = time();
&get_time_now;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
@@ -252,6 +252,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
if ($DBX) {print "CONNECTED TO DATABASE: $VARDB_server|$VARDB_database\n";}
&get_time_now;
#############################################
##### START QUEUEMETRICS LOGGING LOOKUP #####
@@ -309,7 +310,7 @@ while ($master_loop<$CLIloops)
$DBvd_server_logs = "$aryA[0]";
$DBSERVER_GMT = "$aryA[1]";
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
else {$SYSLOG = '0';}
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
$rec_count++;
}
@@ -587,7 +588,7 @@ sub get_time_now
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$Fhour = "0$hour";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$file_date = "$year-$mon-$mday";
@@ -633,6 +634,31 @@ sub get_time_now
if ($Vmon < 10) {$Vmon = "0$Vmon";}
if ($Vmday < 10) {$Vmday = "0$Vmday";}
$VDL_one = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec";
$timeclock_end_of_day_NOW=0;
### Grab system_settings values from the database
$stmtA = "SELECT count(*) from system_settings where timeclock_end_of_day LIKE \"%$current_hourmin%\";";
if ($DBX) {print "|$stmtA|\n";}
$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;
$timeclock_end_of_day_NOW = "$aryA[0]";
}
$sthA->finish();
if ($timeclock_end_of_day_NOW > 0)
{
$event_string = "End of Day, shutting down this script in 10 seconds, script will resume in 60 seconds...";
if ($DB) {print "\n$event_string\n\n\n";}
&event_logger;
sleep(10);
exit;
}
}
@@ -1217,6 +1243,8 @@ sub launch_inbound_gather
sub calculate_drops_inbound
{
$answer_sec_pct_rt_stat_one = '20';
$answer_sec_pct_rt_stat_two = '30';
# GET inbound group hold stat seconds settings
$stmtA = "SELECT answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two from vicidial_inbound_groups where group_id='$group_id[$p]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+145 -19
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_cleanup_agent_log.pl version 2.0.5
# AST_cleanup_agent_log.pl version 2.2.0
#
# DESCRIPTION:
# to be run frequently to clean up the vicidial_agent_log to fix erroneous time
@@ -45,6 +45,7 @@ if (length($ARGV[0])>1)
print " [-more-than-24hours] = will clean up logs older than 24 hours only\n";
print " [-skip-queue-log-inserts] = will skip only the queue_log missing record checks\n";
print " [-only-check-agent-login-lags] = will only fix queue_log missing PAUSEREASON records\n";
print " [-only-qm-live-call-check] = will only check the queue_log calls that report as live, in ViciDial\n";
print " [-q] = quiet, no output\n";
print " [-test] = test\n";
print " [-debug] = verbose debug messages\n";
@@ -83,6 +84,11 @@ if (length($ARGV[0])>1)
$login_lagged_check=1;
if ($Q < 1) {print "\n----- ONLY LOGIN LAGGED CHECK -----\n\n";}
}
if ($args =~ /-only-qm-live-call-check/i)
{
$qm_live_call_check=1;
if ($Q < 1) {print "\n----- QM LIVE CALL CHECK -----\n\n";}
}
if ($args =~ /-last-24hours/i)
{
$TWENTYFOUR_HOURS=1;
@@ -108,6 +114,17 @@ else
# define time restrictions for queries in script
$secX = time();
$HDtarget = ($secX - 150); # 2.5 minutes in the past
($Hsec,$Hmin,$Hhour,$Hmday,$Hmon,$Hyear,$Hwday,$Hyday,$Hisdst) = localtime($HDtarget);
$Hyear = ($Hyear + 1900);
$Hmon++;
if ($Hmon < 10) {$Hmon = "0$Hmon";}
if ($Hmday < 10) {$Hmday = "0$Hmday";}
if ($Hhour < 10) {$Hhour = "0$Hhour";}
if ($Hmin < 10) {$Hmin = "0$Hmin";}
if ($Hsec < 10) {$Hsec = "0$Hsec";}
$HDSQLdate = "$Hyear-$Hmon-$Hmday $Hhour:$Hmin:$Hsec";
$FDtarget = ($secX - 600); # 10 minutes in the past
($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FDtarget);
$Fyear = ($Fyear + 1900);
@@ -132,6 +149,7 @@ if ($Tsec < 10) {$Tsec = "0$Tsec";}
$VDAD_SQL_time = "and event_time > \"$TDSQLdate\" and event_time < \"$FDSQLdate\"";
$QM_SQL_time = "and time_id > $TDtarget and time_id < $FDtarget";
$QM_SQL_time_H = "and time_id > $TDtarget and time_id < $HDtarget";
if ($ALL_TIME > 0)
{
@@ -153,6 +171,7 @@ if ($TWENTYFOUR_HOURS > 0)
$VDAD_SQL_time = "and event_time > \"$TDSQLdate\" and event_time < \"$FDSQLdate\"";
$QM_SQL_time = "and time_id > $TDtarget and time_id < $FDtarget";
$QM_SQL_time_H = "and time_id > $TDtarget and time_id < $HDtarget";
}
if ($TWENTYFOUR_OLDER > 0)
{
@@ -169,6 +188,7 @@ if ($TWENTYFOUR_OLDER > 0)
$VDAD_SQL_time = "and event_time < \"$TDSQLdate\"";
$QM_SQL_time = "and time_id < $TDtarget";
$QM_SQL_time_H = "and time_id < $TDtarget";
}
# default path to astguiclient configuration file:
@@ -212,6 +232,7 @@ foreach(@conf)
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$CLEANLOGfile) {$CLEANLOGfile = "$PATHlogs/clean.$Hyear-$Hmon-$Hmday";}
if (!$VARDB_port) {$VARDB_port='3306';}
@@ -226,34 +247,135 @@ $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics
$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;
$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]";
$rec_count++;
$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 #####
###########################################
### BEGIN FIX LOGIN/LAGGED PAUSEREASON ENTRIES
if ( ($enable_queuemetrics_logging > 0) && ($login_lagged_check > 0) )
### BEGIN CHECKING ENTERQUEUE/CALLOUTBOUND ENTRIES FOR LIVE CALLS
if ($enable_queuemetrics_logging > 0)
{
if ($DB) {print " - Checking for LOGIN and LAGGED pausereason records in queue_log\n";}
if ($DB) {print " - Checking queue_log in-queue calls in ViciDial\n";}
$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";}
##############################################################
##### grab all queue_log entries for ENTERQUEUE verb to validate
$stmtB = "SELECT time_id,call_id,queue,verb,serverid FROM queue_log where verb IN('ENTERQUEUE','CALLOUTBOUND') and serverid='$queuemetrics_log_id' $QM_SQL_time_H order by time_id;";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$EQenter_records=$sthB->rows;
if ($DB) {print "ENTERQUEUE Records: $EQenter_records|$stmtB|\n\n";}
$h=0;
while ($EQenter_records > $h)
{
@aryB = $sthB->fetchrow_array;
$time_id[$h] = $aryB[0];
$call_id[$h] = $aryB[1];
$queue[$h] = $aryB[2];
$verb[$h] = $aryB[3];
$serverid[$h] = $aryB[4];
$h++;
}
$sthB->finish();
$h=0;
while ($EQenter_records > $h)
{
$EQend_count=0;
##### find the CONNECT/ABANDON/COMPLETEAGENT/COMPLETECALLER/CALLSTATUS/EXITWITHKEY/EXITWITHTIMEOUT count for each record
$stmtB = "SELECT count(*) FROM queue_log where verb IN('CONNECT','ABANDON','COMPLETEAGENT','COMPLETECALLER','CALLSTATUS','EXITWITHKEY','EXITWITHTIMEOUT') and call_id='$call_id[$h]';";
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
$CQ_records=$sthB->rows;
if ($CQ_records > 0)
{
@aryB = $sthB->fetchrow_array;
$EQend_count = $aryB[0];
}
$sthB->finish();
if ($EQend_count < 1)
{
if ($DB) {print "IN-QUEUE CALL: $h|$time_id[$h]|$call_id[$h]|$verb[$h]|$serverid[$h]\n";}
$VAClive_count=0;
$VLAlive_count=0;
$stmtA = "SELECT count(*) FROM vicidial_auto_calls where callerid='$call_id[$h]';";
$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;
$VAClive_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) FROM vicidial_live_agents where callerid='$call_id[$h]';";
$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;
$VLAlive_count = $aryA[0];
}
$sthA->finish();
if ( ($VLAlive_count < 1) && ($VAClive_count < 1) )
{
$EQdead++;
if ($DB) {print " DEAD IN-QUEUE queue_log CALL: $EQdead|$call_id[$h]|$VLAlive_count|$VAClive_count\n";}
$newtimeABANDON = ($time_id[$h] + 1);
##### insert an ABANDON record for this call into the queue_log
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$newtimeABANDON',call_id='$call_id[$h]',queue='$queue[$h]',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='1',serverid='$serverid[$h]';";
if ($TEST < 1)
{
$Baffected_rows = $dbhB->do($stmtB);
}
if ($DB) {print " ABANDON record inserted: $Baffected_rows|$stmtB|\n";}
$event_string = "DEAD IN-QUEUE CALL: $h|$EQdead|$time_id[$h]|$call_id[$h]|$queue[$h]|$verb[$h]|$serverid[$h]|$VLAlive_count|$VAClive_count|$Baffected_rows|$stmtB";
&event_logger;
}
}
$h++;
}
if ($qm_live_call_check > 0)
{
exit;
}
}
### END CHECKING ENTERQUEUE/CALLOUTBOUND ENTRIES FOR LIVE CALLS
### BEGIN FIX LOGIN/LAGGED PAUSEREASON ENTRIES (not a recurring process that needs to be run)
if ( ($enable_queuemetrics_logging > 0) && ($login_lagged_check > 0) )
{
if ($DB) {print " - Checking for LOGIN and LAGGED pausereason records in queue_log\n";}
$PAUSEREASONinsert=0;
##############################################################
##### grab all queue_log entries for AGENTLOGIN verb to validate
@@ -461,11 +583,6 @@ if ($DB) {print STDERR " Bad Dispo times zeroed out: $affected_rows\n";}
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";}
if ($skip_queue_log_inserts < 1)
{
$COMPLETEinsert=0;
@@ -889,3 +1006,12 @@ exit;
sub event_logger
{
### open the log file for writing ###
open(Lout, ">>$CLEANLOGfile")
|| die "Can't open $CLEANLOGfile: $!\n";
print Lout "$HDSQLdate|$event_string|\n";
close(Lout);
$event_string='';
}
+6 -2
View File
@@ -408,6 +408,7 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
### recording mixing/compressing/ftping scripts
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl --MIX
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
#2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
@@ -427,8 +428,11 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
### flush queue DB table every hour for entries older than 1 hour
11 * * * * /usr/share/astguiclient/AST_flush_DBqueue.pl -q
### fix the vicidial_agent_log once every hour
### fix the vicidial_agent_log once every hour and the full day run at night
33 * * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl
50 0 * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl --last-24hours
## uncomment below if using QueueMetrics
#*/5 * * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl --only-qm-live-call-check
### updater for VICIDIAL hopper
* * * * * /usr/share/astguiclient/AST_VDhopper.pl -q
@@ -443,7 +447,7 @@ PHASE 6: ADDING CRONTAB ENTRIES FOR ASTGUICLIENT/VICIDIAL SCRIPTS
3 1 * * * /usr/share/astguiclient/AST_DB_optimize.pl
## adjust time on the server with ntp
30 * * * * /usr/local/bin/ntpdate -u ntp.myfloridacity.us 2>/dev/null 1>&2
30 * * * * /usr/local/bin/ntpdate -u pool.ntp.org 2>/dev/null 1>&2
### VICIDIAL agent time log weekly summary report generation
2 0 * * 0 /usr/share/astguiclient/AST_agent_week.pl
+2 -1
View File
@@ -181,6 +181,7 @@ agent actions - used by vicidial.php, vdc_db_query.php and AST_VDremote_agents.p
call actions before going to agent - used by agi-VDAD_ALL_inbound/outbound scripts
ENTERQUEUE(url|callerid)
CALLOUTBOUND(url|callerid)
CONNECT(holdtime)
EXITWITHTIMEOUT(position)
EXITWITHKEY(key|position)
@@ -207,7 +208,7 @@ data1: call termination codes, TBD
data2: callerID or number called(sometimes prepended by DNIS) [3101-9015556189]
NOTE: the queuemetrics_eq_prepend field allows you to specify what
vicidial_list field you would like to prefend to the phone number on
ENTERQUEUE events
ENTERQUEUE/CALLOUTBOUND events
data3: ??
+5 -1
View File
@@ -2359,6 +2359,7 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running
### recording mixing/compressing/ftping scripts
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl --MIX
#0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
#2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
@@ -2378,8 +2379,11 @@ SUBPHASE 6.5: setting up astguiclient scripts for continuous running
### flush queue DB table every hour for entries older than 1 hour
11 * * * * /usr/share/astguiclient/AST_flush_DBqueue.pl -q
### fix the vicidial_agent_log once every hour
### fix the vicidial_agent_log once every hour and the full day run at night
33 * * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl
50 0 * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl --last-24hours
## uncomment below if using QueueMetrics
#*/5 * * * * /usr/share/astguiclient/AST_cleanup_agent_log.pl --only-qm-live-call-check
### updater for VICIDIAL hopper
* * * * * /usr/share/astguiclient/AST_VDhopper.pl -q
+1 -1
View File
@@ -1,6 +1,6 @@
VICIDIAL and Vtiger
Current VICIDIAL integration with Vtiger is for the 5.0.4 release version of Vtiger only
Current VICIDIAL integration with Vtiger is for the 5.0.4 release version of Vtiger only (we also have beta support for Vtiger 5.1.0)
Current integration features:
- vicidial.php WEBFORM search for lead/account/vendor
+1 -1
View File
@@ -272,7 +272,7 @@ echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>
$rslt=mysql_query($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03XXX',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where callerid='$Acallerid';";
$stmt="UPDATE vicidial_live_agents set last_state_change='$deadNOW_TIME' where agent_log_id='$Aagent_log_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03XXX',$user,$server_ip,$session_name,$one_mysql_log);}