Added --call-log-only flag to archive log script
Added FastAGIServer code git-svn-id: svn://192.168.202.10@4015 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
# 251024-1518 - Added --vicidial-dial-log-only flag
|
||||
# 260111-2138 - Added --agent-log-only flag
|
||||
# 260516-2149 - Added internal logging
|
||||
# 260826-2206 - Added --call-log-only flag
|
||||
#
|
||||
|
||||
$CALC_TEST=0;
|
||||
@@ -132,6 +133,8 @@ if (length($ARGV[0])>1)
|
||||
print " [--vicidial-dial-log-days=XX] = REQUIRED FOR --vicidial-dial-log-only, number of days to archive vicidial_dial_log table only past\n";
|
||||
print " [--extended-log-only] = OPTIONAL, only archive vicidial_log_extended table then exit\n";
|
||||
print " [--extended-log-days=XX] = REQUIRED FOR --extended-log-only, number of days to archive vicidial_log_extended table only past\n";
|
||||
print " [--call-log-only] = OPTIONAL, only archive call_log table then exit\n";
|
||||
print " [--call-log-days=XX] = REQUIRED FOR --call-log-only, number of days to archive call_log table only past\n";
|
||||
print " [--agent-log-only] = OPTIONAL, only archive vicidial_agent_log table then exit\n";
|
||||
print " [--api-archive-only] = OPTIONAL, only purge vicidial_api_log_archive table then exit\n";
|
||||
print " [--api-archive-days=XX] = REQUIRED FOR --api-archive-only, number of days to purge vicidial_api_log_archive table only past\n";
|
||||
@@ -354,6 +357,25 @@ if (length($ARGV[0])>1)
|
||||
{print "\n----- EXTENDED LOG ARCHIVE ACTIVE, DAYS: $extendeddays -----\n\n";}
|
||||
}
|
||||
|
||||
if ($args =~ /--call-log-only/i)
|
||||
{
|
||||
$call_log_only++;
|
||||
if ($Q < 1)
|
||||
{print "\n----- CALL LOG ARCHIVE ONLY $call_log_only -----\n\n";}
|
||||
}
|
||||
if ($args =~ /--call-log-days=/i)
|
||||
{
|
||||
$call_log_only++;
|
||||
@data_in = split(/--call-log-days=/,$args);
|
||||
$extendeddays = $data_in[1];
|
||||
$extendeddays =~ s/ .*$//gi;
|
||||
$extendeddays =~ s/\D//gi;
|
||||
if ($extendeddays > 999999)
|
||||
{$extendeddays=1825;}
|
||||
if ($Q < 1)
|
||||
{print "\n----- CALL LOG ARCHIVE ACTIVE, DAYS: $extendeddays -----\n\n";}
|
||||
}
|
||||
|
||||
if ($args =~ /--api-archive-only/i)
|
||||
{
|
||||
$api_archive_only++;
|
||||
@@ -536,7 +558,7 @@ if ($url_log_only > 0)
|
||||
if ($URLsec < 10) {$URLsec = "0$URLsec";}
|
||||
$URLdel_time = "$URLyear-$URLmon-$URLmday $URLhour:$URLmin:$URLsec";
|
||||
}
|
||||
if ( ($extended_log_only > 0) || ($vicidial_log_only > 0) || ($vicidial_dial_log_only > 0) )
|
||||
if ( ($extended_log_only > 0) || ($call_log_only > 0) || ($vicidial_log_only > 0) || ($vicidial_dial_log_only > 0) )
|
||||
{
|
||||
$EXTENDEDdel_epoch = ($secX - (86400 * $extendeddays)); # X days ago
|
||||
($EXTENDEDsec,$EXTENDEDmin,$EXTENDEDhour,$EXTENDEDmday,$EXTENDEDmon,$EXTENDEDyear,$EXTENDEDwday,$EXTENDEDyday,$EXTENDEDisdst) = localtime($EXTENDEDdel_epoch);
|
||||
@@ -2058,6 +2080,65 @@ if (!$T)
|
||||
########## END --extended-log-only flag processing ##########
|
||||
|
||||
|
||||
|
||||
########## BEGIN --call-log-only flag processing ##########
|
||||
if ($call_log_only > 0)
|
||||
{
|
||||
##### call_log
|
||||
$stmtA = "SELECT count(*) from call_log;";
|
||||
$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;
|
||||
$call_log_count = $aryA[0];
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$stmtA = "SELECT count(*) from call_log_archive;";
|
||||
$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;
|
||||
$call_log_archive_count = $aryA[0];
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
if (!$Q) {print "\nProcessing call_log table... ($call_log_count|$call_log_archive_count)\n";}
|
||||
$stmtA = "INSERT IGNORE INTO call_log_archive SELECT * from call_log;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
|
||||
$sthArows = $sthA->rows;
|
||||
if (!$Q) {print "$sthArows rows inserted into call_log_archive table \n";}
|
||||
|
||||
$rv = $sthA->err();
|
||||
if (!$rv)
|
||||
{
|
||||
if ($wipe_all > 0)
|
||||
{$stmtA = "DELETE FROM call_log;";}
|
||||
else
|
||||
{$stmtA = "DELETE FROM call_log WHERE start_time < '$EXTENDEDdel_time';";}
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows = $sthA->rows;
|
||||
if (!$Q) {print "$sthArows rows deleted from call_log table \n";}
|
||||
|
||||
$stmtA = "optimize table call_log;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
}
|
||||
|
||||
if (!$Q) {print "\nProcessing call_log table finished: ($sthArows rows deleted) \n";}
|
||||
|
||||
exit;
|
||||
}
|
||||
########## END --call-log-only flag processing ##########
|
||||
|
||||
|
||||
########## BEGIN --vicidial-log-only flag processing ##########
|
||||
if ($vicidial_log_only > 0)
|
||||
{
|
||||
|
||||
@@ -185,9 +185,10 @@
|
||||
# 260515-2121 - Added truncating of vicidial_internal_log entries after 7 days, updating of some records
|
||||
# 260527-0142 - Added dialplan filtering
|
||||
# 260605-1002 - Added end-of-day log processing log entry for the vicidial_internal_log
|
||||
# 260826-1814 - Added FastAGIServer code
|
||||
#
|
||||
|
||||
$build = '260605-1002';
|
||||
$build = '260826-1814';
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$teodDB=0; # flag to log Timeclock End of Day processes to log file
|
||||
@@ -598,6 +599,7 @@ else
|
||||
$AST_VDremote_agents=0;
|
||||
$AST_VDadapt=0;
|
||||
$FastAGI_log=0;
|
||||
$FastAGIServer=0;
|
||||
$email_inbound=0;
|
||||
$AST_VDauto_dial_FILL=0;
|
||||
$ip_relay=0;
|
||||
@@ -619,6 +621,7 @@ else
|
||||
$runningsip_logger=0;
|
||||
$runningconf_updater=0;
|
||||
$runningcrash_test=0;
|
||||
$runningFastAGIServer=0;
|
||||
$AST_conf_3way=0;
|
||||
$AST_rec_monitor=0;
|
||||
|
||||
@@ -682,6 +685,11 @@ else
|
||||
$conf_updater=1;
|
||||
if ($DB) {print "Check to see if conference updater should run\n";}
|
||||
}
|
||||
if ($VARactive_keepalives =~ /F/)
|
||||
{
|
||||
$FastAGIServer=1;
|
||||
if ($DB) {print "FastAGIServer set to keepalive\n";}
|
||||
}
|
||||
if ($cu3way > 0)
|
||||
{
|
||||
$AST_conf_3way=1;
|
||||
@@ -800,6 +808,11 @@ else
|
||||
$runningcrash_test++;
|
||||
if ($DB) {print "AST_table_status RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
if ($psoutput[$i] =~ /$REGhome\/FastAGIServer\/FastAGIServer\.pl/)
|
||||
{
|
||||
$runningFastAGIServer++;
|
||||
if ($DB) {print "FastAGIServer Running: |$psoutput[$i]|\n";}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
@@ -813,7 +826,14 @@ else
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
# if $runningFastAGIServer running, update internal process log
|
||||
if ( ($runningFastAGIServer > 0) && ($reset_test =~ /0$|5$/) )
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage=CONCAT((UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(db_time)),' seconds runtime') WHERE process='FastAGIServer.pl' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
##### Second, IF MORE THAN ONE LISTEN INSTANCE IS RUNNING, KILL THE SECOND ONE #####
|
||||
@@ -889,6 +909,7 @@ else
|
||||
( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) ||
|
||||
( ($AST_VDadapt > 0) && ($runningAST_VDadapt < 1) ) ||
|
||||
( ($FastAGI_log > 0) && ($runningFastAGI_log < 1) ) ||
|
||||
( ($FastAGIServer > 0) && ($runningFastAGIServer < 1) ) ||
|
||||
( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) ||
|
||||
( ($ip_relay > 0) && ($runningip_relay < 1) ) ||
|
||||
( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) ||
|
||||
@@ -998,6 +1019,11 @@ else
|
||||
$runningcrash_test++;
|
||||
if ($DB) {print "AST_table_status RUNNING: |$psline[1]|\n";}
|
||||
}
|
||||
if ($psoutput2[$i] =~ /$REGhome\/FastAGIServer\/FastAGIServer\.pl/)
|
||||
{
|
||||
$runningFastAGIServer++;
|
||||
if ($DB) {print "FastAGIServer Running: |$psoutput2[$i]|\n";}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -1167,6 +1193,13 @@ else
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ($FastAGIServer > 0) && ($runningFastAGIServer < 1) )
|
||||
{
|
||||
# FastAGIServer does not run in a Screen session
|
||||
if ($DB) {print "starting FastAGIServer...\n";}
|
||||
`/usr/bin/screen -d -m -S FastAGIServer $PATHhome/FastAGIServer/FastAGIServer.pl --nofork --loglevel 4`;
|
||||
# `/usr/bin/perl $PATHhome/FastAGIServer/FastAGIServer.pl &`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user