John Hesch

Echoing my thoughts and interests

For some reason my server is seeing spikes in the number of processes which is causing my server load to increase to levels that basically make the server inoperable. This is happening several times a day. Until I find out what the cause is, I implemented some code to check the server load every other minute and if the load is above 5, restart httpd.

PERL:
  1.  
  2. #!/usr/bin/perl -w
  3. #use strict;
  4. $|++;
  5.  
  6. open(LOAD,"/proc/loadavg") || die "couldn't open /proc/loadavg: $!\n";
  7. my @load=split(/ /,<LOAD>);
  8. close(LOAD);
  9.  
  10. if ($load[0] > 5) {
  11. `/sbin/service httpd restart`;
  12. } 

Save this as loadavg.pl and run it with cron. We shall see.

Comments are closed.

Graytone | Design: Tenant Report