Keeping Your Server From Running Out of Disc Space.
Keeping Your Server From Running Out of Disc Space
Not too long ago, I got a panicked IM from someone I know in Blogspace. “Scott my server won’t let me log in to Movable Type. Can you help me?” He shot me a root password and I started reviewing the logs, checking for DB errors, etc. Then either he or I thought of “does it have free disc space”? A quick “df -h” told us /dev/hda1/ was at 100%. That’s bad. So we cleaned up some stuff and I thought he might benefit from some code I wrote a while back. What it does is once per day send me a report via email like this:
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 18G 17G 561M 97% /
/dev/hda1 23M 4.1M 17M 19% /boot
none 250M 0 250M 0% /dev/shm
10.225.183.68:/ 36G 23G 11G 67% /mnt/10.225.183.68
Once a word has been allowed to escape, it cannot be recalled.
— Quintus Horatius Flaccus (Horace)
The key thing here isn’t the code. That’s pretty damn simple. The big deal is that I made it interesting by appending the results of the standard Unix tool fortune to it. Here’s another example:
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 18G 17G 561M 97% /
/dev/hda1 23M 4.1M 17M 19% /boot
none 250M 0 250M 0% /dev/shm
10.225.183.68:/ 36G 23G 11G 67% /mnt/10.225.183.68
If you would understand your own age, read the works of fiction produced
in it. People in disguise speak freely.
We all get way to many automated things via email and if you at least make them interesting then you might bother to read them.
Here’s the php code. There are lots of ways to make it better but I just dashed it off. Perhaps it will be useful.
Note: The real lesson here is that more developers need to start taking user psychology into account. I’ve had boring sysadmin reports before and I used to generally just delete them. Now I actually read them since I never know what might be in them. If I had been a little bit smarter, I would have varied the fortune routine to sometimes give 2 fortunes or 5 or maybe insert a random picture from the net.
[The FuzzyBlog!]