From ee479d83b89aefeb183d662cbe6a311f0f1b5b95 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 14 Aug 2006 22:10:25 +0000 Subject: [PATCH] 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 --- agc_2-X/trunk/bin/AST_VDauto_dial.pl | 44 +++++++++---- agc_2-X/trunk/bin/AST_VDhopper.pl | 38 +++++++---- agc_2-X/trunk/bin/AST_VDremote_agents.pl | 48 ++++++++++---- .../bin/AST_manager_kill_hung_congested.pl | 28 ++++++-- agc_2-X/trunk/bin/AST_manager_listen.pl | 50 +++++++++----- agc_2-X/trunk/bin/AST_manager_send.pl | 65 +++++++++++++++---- agc_2-X/trunk/bin/AST_send_action_child.pl | 15 +++-- agc_2-X/trunk/bin/start_asterisk_boot.pl | 62 +++++++++++++++++- 8 files changed, 274 insertions(+), 76 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index 31b311d4..a0be1d30 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -47,6 +47,7 @@ # - Removed gmt lead validation because it is already done by VDhopper # 60807-1438 - Changed to DBI # - changed to use /etc/astguiclient.conf for configs +# 60814-1749 - added option for no logging to file # @@ -151,9 +152,6 @@ if (!$VARDB_port) {$VARDB_port='3306';} if (!$VDADLOGfile) {$VDADLOGfile = "$PATHlogs/vdautodial.$year-$mon-$mday";} - $event_string='PROGRAM STARTED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||'; - &event_logger; # writes to the log and if debug flag is set prints to STDOUT - use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second use DBI; @@ -161,9 +159,8 @@ 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 telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context 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 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; @@ -182,6 +179,7 @@ while ($sthArows > $rec_count) $DBanswer_transfer_agent= "$aryA[8]"; $DBSERVER_GMT = "$aryA[9]"; $DBext_context = "$aryA[10]"; + $DBvd_server_logs = "$aryA[11]"; if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} @@ -193,6 +191,8 @@ while ($sthArows > $rec_count) if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} $rec_count++; } $sthA->finish(); @@ -419,10 +419,13 @@ while($one_day_interval > 0) if ($lead_id_call_list =~ /\|$lead_id\|/) { print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n"; - open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date") - || die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n"; - print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n"; - close(DUPout); + if ($SYSLOG) + { + open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date") + || die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n"; + print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n"; + close(DUPout); + } } else { @@ -753,6 +756,22 @@ while($one_day_interval > 0) } if ($endless_loop =~ /0$/) # run every ten cycles (about 25 seconds) { + ### 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(); + ### delete call records that are LIVE for over 10 minutes $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$TDSQLdate' and status NOT IN('XFER','CLOSER')"; $affected_rows = $dbhA->do($stmtA); @@ -935,15 +954,14 @@ if ($Tsec < 10) {$Tsec = "0$Tsec";} sub event_logger { - if ($DB) {print "$now_date|$event_string|\n";} +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$VDADLOGfile") || die "Can't open $VDADLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } diff --git a/agc_2-X/trunk/bin/AST_VDhopper.pl b/agc_2-X/trunk/bin/AST_VDhopper.pl index 0b2780f0..bc9a825f 100644 --- a/agc_2-X/trunk/bin/AST_VDhopper.pl +++ b/agc_2-X/trunk/bin/AST_VDhopper.pl @@ -1,7 +1,6 @@ #!/usr/bin/perl # -# AST_VDhopper.pl version 0.11 -# *** DBI version *** +# AST_VDhopper.pl version 2.0.1 *DBI-version* # # DESCRIPTION: # uses DBD::MySQL to update the VICIDIAL leads hopper for the streamlined @@ -39,6 +38,7 @@ # 60614-1159 - Added campaign lead recycling ability # 60715-2251 - changed to use /etc/astguiclient.conf for configs # 60801-1634 - Fixed Callback activation bug 000008 +# 60814-1720 - added option for no logging to file # # constants @@ -181,13 +181,24 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA ### Grab Server values from the database -$stmtA = "SELECT local_gmt FROM servers where server_ip = '$server_ip';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -@aryA = $sthA->fetchrow_array; -$DBSERVER_GMT = $aryA[0]; -if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} -$sthA->finish(); + $stmtA = "SELECT vd_server_logs,local_gmt 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]"; + $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(); + + $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); @@ -1215,15 +1226,16 @@ exit; -sub event_logger { +sub event_logger +{ +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$VDHLOGfile") || die "Can't open $VDHLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } diff --git a/agc_2-X/trunk/bin/AST_VDremote_agents.pl b/agc_2-X/trunk/bin/AST_VDremote_agents.pl index b6a0cee4..531f181e 100644 --- a/agc_2-X/trunk/bin/AST_VDremote_agents.pl +++ b/agc_2-X/trunk/bin/AST_VDremote_agents.pl @@ -26,6 +26,7 @@ # 50810-1615 - Added database server variable definitions lookup # 60807-1003 - Changed to DBI # - changed to use /etc/astguiclient.conf for configs +# 60814-1726 - added option for no logging to file # ### begin parsing run-time options ### @@ -139,13 +140,22 @@ $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 local_gmt FROM servers where server_ip = '$server_ip';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -@aryA = $sthA->fetchrow_array; -$DBSERVER_GMT = $aryA[0]; -if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} -$sthA->finish(); + $stmtA = "SELECT vd_server_logs,local_gmt 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]"; + $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(); &get_time_now; # update time/date variables @@ -169,6 +179,23 @@ while($one_day_interval > 0) if ($endless_loop =~ /0$|5$/) { + ### 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(); + + ### delete call records that are LIVE for over 10 minutes and last_update_time < '$PDtsSQLdate' $stmtA = "DELETE FROM vicidial_live_agents where server_ip='$server_ip' and status IN('PAUSED') and extension LIKE \"R/%\";"; $affected_rows = $dbhA->do($stmtA); @@ -575,15 +602,14 @@ if ($Tsec < 10) {$Tsec = "0$Tsec";} sub event_logger { - if ($DB) {print "$now_date|$event_string|\n";} +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$VDRLOGfile") || die "Can't open $VDRLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } diff --git a/agc_2-X/trunk/bin/AST_manager_kill_hung_congested.pl b/agc_2-X/trunk/bin/AST_manager_kill_hung_congested.pl index e06575a9..38fb2d0d 100644 --- a/agc_2-X/trunk/bin/AST_manager_kill_hung_congested.pl +++ b/agc_2-X/trunk/bin/AST_manager_kill_hung_congested.pl @@ -25,6 +25,7 @@ # 50823-1525 - Added commandline debug options with debug printouts # 60717-1247 - changed to DBI by Marin Blu # 60717-1536 - changed to use /etc/astguiclient.conf for configs +# 60814-1706 - added option for no logging to file # # constants @@ -116,11 +117,29 @@ if (!$VARDB_port) {$VARDB_port='3306';} &get_time_now; +if (!$KHLOGfile) {$KHLOGfile = "$PATHlogs/congest.$year-$mon-$mday";} + 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(); + $stmtA = "SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = 'CONGEST' and channel LIKE \"Local%\" limit 99"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -352,14 +371,15 @@ $CIDdate = "$year$mon$mday$hour$min$sec"; -sub event_logger { +sub event_logger +{ +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$KHLOGfile") || die "Can't open $KHLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } diff --git a/agc_2-X/trunk/bin/AST_manager_listen.pl b/agc_2-X/trunk/bin/AST_manager_listen.pl index a73d2c56..7412c862 100644 --- a/agc_2-X/trunk/bin/AST_manager_listen.pl +++ b/agc_2-X/trunk/bin/AST_manager_listen.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# AST_manager_listen.pl version 1.1.12 *DBI-version* +# AST_manager_listen.pl version 2.0.1 *DBI-version* # # Part of the Asterisk Central Queue System (ACQS) # @@ -37,6 +37,7 @@ # 60718-0909 - changed to DBI by Marin Blu # 60718-0955 - changed to use /etc/astguiclient.conf for configs # 60720-1142 - added keepalive to MySQL connection every 50 seconds +# 60814-1733 - 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,12 +136,8 @@ use Net::Telnet (); $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; - $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; - &event_logger; - - ### 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 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 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; @@ -162,6 +156,7 @@ while ($sthArows > $rec_count) $DBanswer_transfer_agent= "$aryA[8]"; $DBSERVER_GMT = "$aryA[9]"; $DBext_context = "$aryA[10]"; + $DBvd_server_logs = "$aryA[11]"; if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} @@ -173,12 +168,17 @@ while ($sthArows > $rec_count) if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;} if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;} if ($DBext_context) {$ext_context = $DBext_context;} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} $rec_count++; } $sthA->finish(); if (!$telnet_port) {$telnet_port = '5038';} + $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; + &event_logger; + $one_day_interval = 90; # 1 day loops for 3 months while($one_day_interval > 0) { @@ -518,6 +518,22 @@ 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(); + ### Grab Server values to keep DB connection alive $stmtA = "SELECT last_update FROM server_updater where server_ip = '$server_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -589,15 +605,16 @@ $action_log_date = "$year-$mon-$mday"; -sub event_logger { +sub event_logger +{ +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$PATHlogs/listen_process.$action_log_date") || die "Can't open $PATHlogs/listen_process.$action_log_date: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } @@ -606,10 +623,11 @@ $event_string=''; sub manager_output_logger { -open(MOout, ">>$PATHlogs/listen.$action_log_date") +if ($SYSLOG) + { + open(MOout, ">>$PATHlogs/listen.$action_log_date") || die "Can't open $PATHlogs/listen.$action_log_date: $!\n"; - print MOout "$now_date|$manager_string|\n"; - close(MOout); + } } diff --git a/agc_2-X/trunk/bin/AST_manager_send.pl b/agc_2-X/trunk/bin/AST_manager_send.pl index 597adee2..6989a6ec 100644 --- a/agc_2-X/trunk/bin/AST_manager_send.pl +++ b/agc_2-X/trunk/bin/AST_manager_send.pl @@ -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=''; } diff --git a/agc_2-X/trunk/bin/AST_send_action_child.pl b/agc_2-X/trunk/bin/AST_send_action_child.pl index eb5c68cf..288bcedb 100644 --- a/agc_2-X/trunk/bin/AST_send_action_child.pl +++ b/agc_2-X/trunk/bin/AST_send_action_child.pl @@ -36,6 +36,7 @@ # 50902-1032 - Changed default logging to fulllog # 60718-0909 - changed to DBI by Marin Blu # 60718-1024 - changed to use /etc/astguiclient.conf for configs +# 60814-1720 - added option for no logging to file # $FULL_LOG = 1; # set to 1 for a full response log to be created in $PATHlogs/action_full.date @@ -157,7 +158,7 @@ use Net::Telnet (); or die "Couldn't connect to database: " . DBI->errstr; ### Grab Server values from the database - $stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEsend FROM servers where server_ip = '$server_ip';"; + $stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEsend,vd_server_logs 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; @@ -170,11 +171,14 @@ use Net::Telnet (); $DBASTmgrUSERNAME = "$aryA[2]"; $DBASTmgrSECRET = "$aryA[3]"; $DBASTmgrUSERNAMEsend = "$aryA[4]"; + $DBvd_server_logs = "$aryA[5]"; if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;} if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;} if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;} if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;} if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} $rec_count++; } $sthA->finish(); @@ -290,14 +294,15 @@ print "DONE execute time: $script_time seconds\n"; exit; -sub full_event_logger { +sub full_event_logger +{ +if ($SYSLOG) + { ### open the log file for writing ### open(Lout, ">>$PATHlogs/action_full.$action_log_date") || die "Can't open $PATHlogs/action_full.$action_log_date: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); - + } $event_string=''; } diff --git a/agc_2-X/trunk/bin/start_asterisk_boot.pl b/agc_2-X/trunk/bin/start_asterisk_boot.pl index 71a1874c..03a735ab 100644 --- a/agc_2-X/trunk/bin/start_asterisk_boot.pl +++ b/agc_2-X/trunk/bin/start_asterisk_boot.pl @@ -3,10 +3,68 @@ # # Copyright (C) 2006 Matt Florell LICENSE: GPLv2 # +# CHANGES +# +# 60814-1658 - added option to start without logging through servers table setting +# -print "\nStarting Asterisk...n"; +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; -`/usr/bin/screen -L -d -m -S asterisk /usr/sbin/asterisk -vvvvvvvvvvvvvvvvvvvvvgc`; +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +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(); + +if ($SYSLOG) + { + print "\nStarting Asterisk... screen logging on\n"; + `/usr/bin/screen -L -d -m -S asterisk /usr/sbin/asterisk -vvvvvvvvvvvvvvvvvvvvvgc`; + } +else + { + print "\nStarting Asterisk... screen logging off\n"; + `/usr/bin/screen -d -m -S asterisk /usr/sbin/asterisk -vvvvgc`; + } print "Asterisk started\n";