[Melbourne-pm] Detecting Hardware limits / problems

David Dick david_dick at iprimus.com.au
Wed Jan 26 11:45:12 PST 2005

One of my earliest perl experiences was being put in charge of a crusty 
horrific set of cgi scripts that powered a fairly popular web site 
(around 1-2 hits per second on average).  Popularity was building thou,
and soon after i was put in charge, things would just go beserk.  The 
error logs would suddenly fill with completely confusing error messages 
about how the code base wasn't compiling, .pl files were not being 
required successfully, etc.  I guessed in the end that the machine had 
run out of memory because it had spawned too many cgi-scripts and set 
about repairing things.

however, the mental scarring is still there and the question is, are 
there are special tricks that people use to

1) detect a hardware limit or problem and write a message to stderr?
2) stop a hardware limit or problem from filling stderr with tons of 
verbose, misleading messages about the effects of the problem, instead 
of the cause?

The point of this would be to as quickly as possible, alert the owner of 
the program that hardware failure or a hardware limit has occurred.

Hardware failure / limits i think mean running out of ram, running out 
of hard disk or hard disk failure.  cpu failure i don't think is 
detectable, likewise bad memory, although quite possibly i'm wrong. 
hardware is one of my many weaknesses. :)

Things i can think of.

Always check the return value of system calls. :) Not really as simple 
as that unfortunately.  Failing to open a file for reading _may_ mean 
the hard disk has failed, or that the user has messed up the 
installation of the program.  Maybe use some sort of variable to keep 
track of this? On the other hand, i've never seen a seek fail at all, 
and maybe it would only fail if the hard drive failed.

Always use some type of eval { require foo; }; if ($@) { panic; } type 
construct to load libraries???

hoping the new year won't involve this sort of stuff for any of you :)

More information about the Melbourne-pm mailing list