Fixed extended alt dial bug in agent scripts

Changed agent screen to not delete session reservations at logout, instead ADMIN_keepalive will clear them out once a day at timeclock reset time
Changed callback purge to clear out ACTIVE callbacks older than month/week as well as LIVE

git-svn-id: svn://192.168.202.10@1202 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2009-08-12 05:44:35 +00:00
parent c0bbceebb6
commit cf282e76fe
8 changed files with 313 additions and 152 deletions
+75 -4
View File
@@ -8,6 +8,7 @@
#
# Other functions of this program:
# - Launches the timeclock auto-logout process
# - clear out non-used vicidial_conferences sessions
# - Generates Asterisk conf files and reloads Asterisk
# - Synchronizes the audio store files
# - Runs trigger processes at defined times
@@ -37,6 +38,7 @@
# 90630-2259 - Added vicidial_process_triggers functionality
# 90713-0140 - Changed direct dial phone extensions to failover to voicemail forwarder
# 90722-1102 - Added list reset by time option
# 90812-0053 - Added clear out non-used vicidial_conferences sessions
#
$DB=0; # Debug flag
@@ -49,7 +51,7 @@ $mon++;
$wtoday = $wday;
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";}
$now_date = "$year-$mon-$mday $hour:$min:$sec";
@@ -478,10 +480,8 @@ if ($timeclock_auto_logout > 0)
################################################################################
##### START Creation of auto-generated conf files
##### START clear out non-used vicidial_conferences sessions
################################################################################
# default path to astguiclient configuration file:
@@ -525,6 +525,77 @@ use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
$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 \"%$reset_test%\";";
if ($DB) {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)
{
if ($DB) {print "Starting clear out non-used vicidial_conferences sessions process...\n";}
$stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='0';";
if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$VCexten_ct=$sthA->rows;
$rec_count=0;
while ($VCexten_ct > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PT_conf_extens[$rec_count] = $aryA[0];
$PT_extensions[$rec_count] = $aryA[1];
if ($DBX) {print "|$PT_conf_extens[$rec_count]|$PT_extensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
$k=0;
while ($k < $rec_count)
{
$live_session=0;
$stmtA = "SELECT count(*) from vicidial_live_agents where conf_exten='$PT_conf_extens[$k]' and server_ip='$server_ip';";
$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;
$live_session = "$aryA[0]";
}
$sthA->finish();
if ($live_session < 1)
{
$stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
}
$k++;
}
}
################################################################################
##### END clear out non-used vicidial_conferences sessions
################################################################################
################################################################################
##### START Creation of auto-generated conf files
################################################################################
##### Get the settings from system_settings #####
$stmtA = "SELECT sounds_central_control_active,active_voicemail_server FROM system_settings;";
# print "$stmtA\n";
+63 -62
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# ADMIN_timeclock_auto_logout.pl version 2.0.5 *DBI-version*
# ADMIN_timeclock_auto_logout.pl version 2.2.0 *DBI-version*
#
# DESCRIPTION:
# forces logout of all users still logged into the timeclock
@@ -8,11 +8,12 @@
# This script is launched by the ADMIN_keepalive_ALL.pl script with the '9' flag
# defined in astguiclient.conf
#
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 80526-0958 - First Build
# 80604-0733 - fixed minor bug in update
# 80604-0733 - Fixed minor bug in update
# 90812-0103 - Formatting fixes
#
# constants
@@ -38,47 +39,47 @@ $HHMM = "$hour$min";
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--force-run] = force run even if already run for the day\n\n";
exit;
}
{
print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--force-run] = force run even if already run for the day\n\n";
exit;
}
else
{
{
if ($args =~ /--force-run/i)
{
$force_run=1;
print "\n----- FORCE RUN -----\n\n";
}
{
$force_run=1;
print "\n----- FORCE RUN -----\n\n";
}
if ($args =~ /--debug/i)
{
$DB=1;
print "\n----- DEBUG -----\n\n";
}
{
$DB=1;
print "\n----- DEBUG -----\n\n";
}
if ($args =~ /--debugX/i)
{
$DBX=1;
print "\n----- SUPER DEBUG -----\n\n";
}
{
$DBX=1;
print "\n----- SUPER DEBUG -----\n\n";
}
if ($args =~ /-t/i)
{
$T=1; $TEST=1;
print "\n-----TESTING -----\n\n";
{
$T=1; $TEST=1;
print "\n-----TESTING -----\n\n";
}
}
}
}
else
{
print "no command line options set\n";
}
{
print "no command line options set\n";
}
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
@@ -135,13 +136,13 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBSERVER_GMT = "$aryA[1]";
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
$rec_count++;
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBSERVER_GMT = "$aryA[1]";
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
$rec_count++;
}
$sthA->finish();
@@ -152,9 +153,9 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$timeclock_end_of_day = "$aryA[0]";
$timeclock_last_reset_date = "$aryA[1]";
@aryA = $sthA->fetchrow_array;
$timeclock_end_of_day = "$aryA[0]";
$timeclock_last_reset_date = "$aryA[1]";
}
$sthA->finish();
@@ -165,7 +166,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$nowtest = ($HHMM+0);
$logtest = ($timeclock_end_of_day+0);
if ( ($force_run > 0) || ( ($nowtest >= $logtest) && ($timeclock_last_reset_date ne "$file_date") ) )
{
{
@user=@MT;
### grab users that are currently logged-in to the timeclock
@@ -239,20 +240,20 @@ if ( ($force_run > 0) || ( ($nowtest >= $logtest) && ($timeclock_last_reset_date
$event_string = "SYSTEM SETTINGS UPDATE|$affected_rows|$stmtA|";
&event_logger;
}
}
else
{
print "cannot run: |$force_run|$HHMM($nowtest)|$timeclock_end_of_day($logtest)|$timeclock_last_reset_date|$file_date|\n";
}
{
print "cannot run: |$force_run|$HHMM($nowtest)|$timeclock_end_of_day($logtest)|$timeclock_last_reset_date|$file_date|\n";
}
if($DB)
{
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secT);
{
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secT);
if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";}
}
if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";}
}
$dbhA->disconnect();
@@ -261,15 +262,15 @@ exit;
sub event_logger
{
if ($SYSLOG)
{
### open the log file for writing ###
open(Lout, ">>$VDALOGfile")
|| die "Can't open $VDALOGfile: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
if ($SYSLOG)
{
### open the log file for writing ###
open(Lout, ">>$VDALOGfile")
|| die "Can't open $VDALOGfile: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
}
$event_string='';
}
$event_string='';
}
+64 -63
View File
@@ -22,36 +22,36 @@ $MT[0]='';
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n";
}
{
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n\n";
}
else
{
{
if ($args =~ /-debug/i)
{
$DB=1; # Debug flag
print "-- DEBUGGING ENABLED --\n\n";
}
{
$DB=1; # Debug flag
print "-- DEBUGGING ENABLED --\n\n";
}
if ($args =~ /-t/i)
{
$TEST=1;
$T=1;
{
$TEST=1;
$T=1;
}
}
}
}
else
{
# print "no command line options set\n";
}
{
# print "no command line options set\n";
}
### end parsing run-time options ###
# default path to astguiclient configuration file:
@@ -113,29 +113,29 @@ $sthArows=$sthA->rows;
$rec_count=0;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = "$aryA[0]";
$DBtelnet_port = "$aryA[1]";
$DBASTmgrUSERNAME = "$aryA[2]";
$DBASTmgrSECRET = "$aryA[3]";
$DBASTmgrUSERNAMEupdate = "$aryA[4]";
$DBASTmgrUSERNAMElisten = "$aryA[5]";
$DBASTmgrUSERNAMEsend = "$aryA[6]";
$DBmax_vicidial_trunks = "$aryA[7]";
$DBanswer_transfer_agent= "$aryA[8]";
$DBSERVER_GMT = "$aryA[9]";
$DBext_context = "$aryA[10]";
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = "$aryA[0]";
$DBtelnet_port = "$aryA[1]";
$DBASTmgrUSERNAME = "$aryA[2]";
$DBASTmgrSECRET = "$aryA[3]";
$DBASTmgrUSERNAMEupdate = "$aryA[4]";
$DBASTmgrUSERNAMElisten = "$aryA[5]";
$DBASTmgrUSERNAMEsend = "$aryA[6]";
$DBmax_vicidial_trunks = "$aryA[7]";
$DBanswer_transfer_agent= "$aryA[8]";
$DBSERVER_GMT = "$aryA[9]";
$DBext_context = "$aryA[10]";
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;}
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
}
$sthA->finish();
@@ -163,14 +163,14 @@ if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDnum = "$Tyear$Tmon$Tmday$Thour$Tmin$Tsec";
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDnum = "$Tyear$Tmon$Tmday$Thour$Tmin$Tsec";
######################################################################
##### CLEAR vicidial_conferences ENTRIES IN LEAVE-3WAY FOR MORE THAN ONE HOUR
######################################################################
@PTextensions=@MT; @PT_conf_extens=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT;
$stmtA = "SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and leave_3way='1' and leave_3way_datetime < \"$TDSQLdate\";";
$stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='1' and leave_3way_datetime < \"$TDSQLdate\";";
if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -180,7 +180,8 @@ while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PT_conf_extens[$rec_count] = "$aryA[0]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PTextensions[$rec_count]|\n";}
$PT_extensions[$rec_count] = "$aryA[0]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PT_extensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
@@ -217,13 +218,13 @@ $sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PTextensions[$rec_count] = "$aryA[0]";
$PT_conf_extens[$rec_count] = "$aryA[1]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PTextensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
@aryA = $sthA->fetchrow_array;
$PTextensions[$rec_count] = "$aryA[0]";
$PT_conf_extens[$rec_count] = "$aryA[1]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PTextensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
if (!$telnet_port) {$telnet_port = '5038';}
@@ -333,13 +334,13 @@ $sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PTextensions[$rec_count] = "$aryA[0]";
$PT_conf_extens[$rec_count] = "$aryA[1]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PTextensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
@aryA = $sthA->fetchrow_array;
$PTextensions[$rec_count] = "$aryA[0]";
$PT_conf_extens[$rec_count] = "$aryA[1]";
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PTextensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
if (!$telnet_port) {$telnet_port = '5038';}
@@ -348,8 +349,8 @@ $t = new Net::Telnet (Port => $telnet_port,
Prompt => '/.*[\$%#>] $/',
Output_record_separator => '',);
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
else {$telnet_login = $ASTmgrUSERNAME;}
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login