added option to disable file logging for vicidial server-side scripts

git-svn-id: svn://192.168.202.10@171 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2006-08-14 22:10:25 +00:00
parent 6f100f8092
commit ee479d83b8
8 changed files with 274 additions and 76 deletions
+53 -12
View File
@@ -32,6 +32,7 @@
# 60718-0909 - changed to DBI by Marin Blu
# 60718-1005 - changed to use /etc/astguiclient.conf for configs
# 60718-1211 - removed need for ADMIN_keepalive_send_listen.at launching
# 60814-1712 - added option for no logging to file
#
# constants
@@ -127,9 +128,6 @@ if (!$VARDB_port) {$VARDB_port='3306';}
&get_time_now;
$event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
&event_logger;
#use lib './lib', '../lib';
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
@@ -138,6 +136,23 @@ 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;
### Grab Server values from the database
$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)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
}
$sthA->finish();
$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|';
&event_logger;
@@ -256,7 +271,14 @@ while($one_day_interval > 0)
$launch_string = "$PATHhome/AST_send_action_child.pl --data1=$man_id $callid $uniqueid $channel";
# &launch_logger;
system("$PATHhome/AST_send_action_child.pl --data1=$man_id >> $PATHlogs/action_send.$action_log_date \&");
if ($SYSLOG)
{
system("$PATHhome/AST_send_action_child.pl --data1=$man_id >> $PATHlogs/action_send.$action_log_date \&");
}
else
{
system("$PATHhome/AST_send_action_child.pl --data1=$man_id \&");
}
$launch_string = "SENT $man_id $callid $uniqueid $channel";
# &launch_logger;
@@ -308,6 +330,23 @@ while($one_day_interval > 0)
{
&get_time_now;
### Grab Server values from the database
$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)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
}
$sthA->finish();
if( ($COUNTER_OUTPUT) or ($DB) ){print "checking to see if listener is dead |$sendonlyone|$running_listen|\n";}
#@psoutput = `/bin/ps -f --no-headers -A`;
@psoutput = `/bin/ps -o "%p %a" --no-headers -A`;
@@ -390,26 +429,28 @@ $action_log_date = "$year-$mon-$mday";
sub event_logger {
sub event_logger
{
if ($SYSLOG)
{
### open the log file for writing ###
open(Lout, ">>$PATHlogs/action_process.$action_log_date")
|| die "Can't open $PATHlogs/action_process.$action_log_date: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
}
$event_string='';
}
sub launch_logger {
sub launch_logger
{
if ($SYSLOG)
{
### open the log file for writing ###
open(LLout, ">>$PATHlogs/action_launch.$action_log_date")
|| die "Can't open $PATHlogs/action_launch.$action_log_date: $!\n";
print LLout "$now_date|$launch_string|\n";
close(LLout);
}
$event_string='';
}