From e7b7bff1bb09e917190a92dd76aa4e547996b033 Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 18 Jul 2006 16:14:55 +0000 Subject: [PATCH] updated AST_manager_send to not need ADMIN_keepalive_send_listen.at script updated keepalive send-listen script to be able to kill extra listen processes fixed keepalive send-listen double-checking git-svn-id: svn://192.168.202.10@77 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/ADMIN_keepalive_AST_send_listen.pl | 109 +++++++++++++++++++++---- bin/AST_manager_send.pl | 4 +- 2 files changed, 98 insertions(+), 15 deletions(-) diff --git a/bin/ADMIN_keepalive_AST_send_listen.pl b/bin/ADMIN_keepalive_AST_send_listen.pl index bdf94ead..6af068e1 100644 --- a/bin/ADMIN_keepalive_AST_send_listen.pl +++ b/bin/ADMIN_keepalive_AST_send_listen.pl @@ -11,6 +11,8 @@ # # 50810-1450 - removed '-L' flag for screen logging of output (optimization) # 50823-1440 - Added commandline debug options with debug printouts +# 60718-1045 - changed to use /etc/astguiclient.conf for configs +# 60718-1213 - fixed double-check and added kill for multiple listen processes # $DB=0; # Debug flag @@ -55,8 +57,21 @@ else } ### end parsing run-time options ### - sleep(1); +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; +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 =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + $i++; + } #@psoutput = `ps -f -C AST_manager --no-headers`; #@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; @@ -75,23 +90,33 @@ if ($DBX) {print "$i|$psoutput[$i]| \n";} if ($psline[1] =~ /AST_manager_li/) { + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $listen_pid[$running_listen] = $psoutput[$i]; $running_listen++; - if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";} + if ($DB) {print "LISTEN RUNNING: |$psline[1]|$psoutput[$i]|\n";} } if ($psline[1] =~ /AST_manager_se/) { + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $send_pid[$running_send] = $psoutput[$i]; $running_send++; - if ($DB) {print "SEND RUNNING: |$psline[1]|\n";} + if ($DB) {print "SEND RUNNING: |$psline[1]|$psoutput[$i]|\n";} } $i++; } +@psline=@MT; +@psoutput=@MT; +@listen_pid=@MT; +@send_pid=@MT; -if (!$running_listen) + +##### IF MORE THAN ONE LISTEN INSTANCE IS RUNNING, KILL THE SECOND ONE ##### +if ($running_listen > 1) { - # print "double check that update_11 is not running\n"; +$running_listen=0; sleep(1); @@ -101,16 +126,63 @@ if (!$running_listen) @psoutput = `/bin/ps -o "%p %a" --no-headers -A`; $i=0; -foreach (@psoutput2) +foreach (@psoutput) { - chomp($psoutput2[$i]); + chomp($psoutput[$i]); if ($DBX) {print "$i|$psoutput[$i]| \n";} - @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $listen_pid[$running_listen] = $psoutput[$i]; + + if ($psline[1] =~ /AST_manager_li/) + { + if ($DB) {print "LISTEN RUNNING: |$psline[1]|$psoutput[$i]|\n";} + $running_listen++; + } + + $i++; + } + +if ($running_listen > 1) + { + if ($DB) {print "Killing AST_manager_listen... |$listen_pid[1]|\n";} + `/bin/kill -s 9 $listen_pid[1]`; + } +} + + + +@psline=@MT; +@psoutput=@MT; +@listen_pid=@MT; +@send_pid=@MT; + + + +##### IF LISTEN IS NOT RUNNING, START IT ##### +if (!$running_listen) +{ +$running_listen=0; + sleep(1); + +#@psoutput = `ps -f -C AST_manager --no-headers`; +#@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$i=0; +foreach (@psoutput) + { + chomp($psoutput[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $listen_pid[$running_listen] = $psoutput[$i]; if ($psline[1] =~ /AST_manager_li/) { $running_listen++; - if ($DB) {print "LISTEN RUNNING: |$psline[1]|\n";} + if ($DB) {print "LISTEN RUNNING: |$psline[1]|$psoutput[$i]|\n";} } $i++; @@ -120,18 +192,25 @@ if (!$running_listen) { if ($DB) {print "starting AST_manager_listen...\n";} # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTlisten /home/cron/AST_manager_listen.pl`; + `/usr/bin/screen -d -m -S ASTlisten $PATHhome/AST_manager_listen.pl`; } } +@psline=@MT; +@psoutput=@MT; +@listen_pid=@MT; +@send_pid=@MT; + + +##### IF SEND IS NOT RUNNING, START IT ##### if (!$running_send) { - # print "double check that update_12 is not running\n"; +$running_send=0; - sleep(1); + sleep(2); #@psoutput = `ps -f -C AST_manager --no-headers`; #@psoutput = `ps -f --no-headers -C AST_manager_s*; ps -f --no-headers -C AST_manager_l*`; @@ -143,11 +222,13 @@ foreach (@psoutput) chomp($psoutput[$i]); if ($DBX) {print "$i|$psoutput[$i]| \n";} @psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + $psoutput[$i] =~ s/ .*|\n|\r|\t| //gi; + $send_pid[$running_send] = $psoutput[$i]; if ($psline[1] =~ /AST_manager_se/) { $running_send++; - if ($DB) {print "SEND RUNNING: |$psline[1]|";} + if ($DB) {print "SEND RUNNING: |$psline[1]|$psoutput[$i]|";} } $i++; @@ -157,7 +238,7 @@ if (!$running_send) { if ($DB) {print "starting AST_manager_send...\n";} # add a '-L' to the command below to activate logging - `/usr/bin/screen -d -m -S ASTsend /home/cron/AST_manager_send.pl`; + `/usr/bin/screen -d -m -S ASTsend $PATHhome/AST_manager_send.pl`; } } diff --git a/bin/AST_manager_send.pl b/bin/AST_manager_send.pl index 094ef071..597adee2 100644 --- a/bin/AST_manager_send.pl +++ b/bin/AST_manager_send.pl @@ -31,6 +31,7 @@ # 50902-1051 - Added extra debug output launch sub(commented out) # 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 # # constants @@ -336,7 +337,8 @@ while($one_day_interval > 0) if( ($COUNTER_OUTPUT) or ($DB) ){print "LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT\n";} $event_string='LISTENER DEAD STOPPING PROGRAM... ATTEMPTING TO START keepalive SCRIPT|'; &event_logger; - `/usr/bin/at now < $PATHhome/ADMIN_keepalive_send_listen.at 2>/dev/null 1>&2`; + # `/usr/bin/at now < $PATHhome/ADMIN_keepalive_send_listen.at 2>/dev/null 1>&2`; + `/usr/bin/screen -d -m $PATHhome/ADMIN_keepalive_AST_send_listen.pl 2>/dev/null 1>&2` } }