I wrote this script not so much as a general-purpose utility but rather as a tool to tell me how much time remains when the proverbial shit hits the fan; How much time I have to work with will have a bearing on what method of solving the problem I choose. (Deleting stale files versus lining up more storage off the SAN, etc.)
DeathClock does a few clever things that may not be immediately recognizable on the surface..
It will attempt to predict when you'll run out of space based on a running average of ($samples) readings. The larger the number of samples, the more accurate the reading will be, but it's not recommended that you use a large value on filesystems where the amount of free space remaining is very volatile. For most purposes, a sample window of about 30 cycles does nicely.
DeathClock will also build up something resembling "confidence" that a panic state is imminent. Right now, I have this value hardcoded to 1 hour, i.e. if DeathClock sees that a filesystem has consistently less than one hour remaining, it will nudge its confidence value ($panicStateDuration) higher and higher until it exceeds the user specified panic threshold value ($panicThreshold).
Once this happens, an email is fired off, a timer is set so that the email recipient isn't bothered for another 10 minutes, and DeathClock continues to monitor the situation. Once the 10 minute window has elapsed, and it still sees a panic-worthy situation, it will fire off another email.
You can set up DeathClock to spit out a single answer:
deathclock.pl /home 30 2 1 0 foo@bar.com
..Or, you can have DeathClock monitor the situation live:
deathclock.pl /home 45 1 0 0 foo@bar.com
Play around with it, you'll see. :)
| [reply] |