1 #!/usr/bin/perl -w
 2 # File: httpd_check.pl
 3 # Author: Tom Large - tlarge@thelug.org
 4 # Location: http://www.thelug.org/docs/
 5 # Description: Checks to see if the httpd daemon is running.
 6 
 7 my $fn = "httpd_count";
 8 
 9 system("ps -ef | grep -v grep | grep -c httpd > $fn");
10 
11 open( HTTPDCOUNT, "$fn" );
12 @httpdcount = <HTTPDCOUNT>;
13 close( HTTPDCOUNT );
14 unlink($fn);
15 
16 foreach $httpdcount(@httpdcount)
17   {
18   chomp $httpdcount;
19   if ($httpdcount < 5)
20     {
21     print "uh oh, only \($httpdcount\) processes running.\n";
22     print "Better do something.\n";
23     }
24   else
25     {
26     print "Looks good\n";
27     }
28   }


syntax highlighted by Code2HTML, v. 0.9.1