#!/usr/bin/perl require 5.002; use strict; use sigtrap; ################################################################ # prox_livetst # # restarts the proxy either when it's not running or # something wrong is happening with the proxy ################################################################ $ENV{PATH} = "$ENV{PATH}:/usr/bin:/bin"; my ($hostname, $res); `/bin/touch /tmp/timestamp`; # for checking chomp($hostname = `/bin/hostname`); chomp($res = `/bin/ps -A | /bin/grep prox\$ | /usr/bin/wc -l`); if ($res == 0) { sleep(5); chomp($res = `/bin/ps -A | /bin/grep prox\$ | /usr/bin/wc -l`); } if ($res == 0) { sleep(5); chomp($res = `/bin/ps -A | /bin/grep prox\$ | /usr/bin/wc -l`); } # restart it if anything is wrong if ($res == 0) { print "$hostname : prox is dead, restarting the proxy\n"; open filename, '>> /home/princeton_codeen/exitlog'; my $now = localtime time; print filename "$now prox restarted by prox_livetst\n"; close filename; # start again `./prox_start < /dev/null >& /dev/null`; } else { print "$hostname: prox is live: num = $res \n"; # check getbig chomp($res = `/bin/ps -A | /bin/grep getbig\$ | /usr/bin/wc -l`); if ($res == 0) { print "$hostname : getbig is dead\n"; `./getbig_start < /dev/null >& /dev/null`; } }