Index: [Article Count Order] [Thread]

Date:  Tue, 26 Jun 2007 14:27:38 -0700
From:  "Ken Marcus - Precision Web Hosting, Inc." <kenmarcus (at mark) precisionweb.net>
Subject:  [coba-e:10258] Re: bluequartz.org not responding to  yum update request
To:  <coba-e (at mark) bluequartz.org>
Message-Id:  <288d01c7b838$d2470ea0$6700a8c0@OfficeKen>
References:  <000701c7b822$874f52b0$3e24050a@IBMPAA>
X-Mail-Count: 10258


----- Original Message ----- 

> It should be working now, the httpd process was stuck.
>
> Regards,
>
> Paul Aviles
> Nickel Networks
>

In case any one else has this problem, this is the script I run once a 
minute with a cron to check the httpd proceses on the BQ servers:


#!/usr/bin/perl
# checks the httpd process and restarts if necessary

$running = "no";
$thecount = 0;

@ps =`ps auxwwwww | grep httpd`;
$aps = "@ps";

foreach $line (@ps){
   if ( ($line =~ /\d \/usr\/sbin\/httpd\n/)  ) {
      #print "all is well\n";
      $running = "yes";
   }
}

#check the count of the processes and make sure they do not have defunct
if (  $running eq "yes" ) {
   foreach $line (@ps){
      if ( ($line =~ /\/usr\/sbin\/httpd/) and ($line !~ /defunct/) and 
($line =~ /apache/) ) {
         $thecount += 1;
      }
   }
   if ($thecount > 3) {
        $running = "yes";
        #print "count is $thecount";
   } else {
        $running = "no";
   }
}



if ($running eq "no") {
         print "httpd problem \n";
         system ("/etc/rc.d/init.d/httpd stop");
         system ("killall -9 httpd");
         system ("/etc/rc.d/init.d/httpd start");

}