Heal Your Church WebSite


Teaching, rebuking, correcting & training in righteous web design.

How to manually monitor your (Linux) server’s storage

For those enjoying the cost benefits Linux hosting there are some downsides. One of those is waking up to the rude reality that your hard-drive is maxed-out ‘fuller than a woman’s purse.

Tomorrow, I swear, I’ll get back to the less geeky stuff … I’ve got a great not-so-nerdy topic for tomorrow.

But for today, a propeller-headed post dedicated to my good friend Chuck Holton, who not only runs LiveFire.us, but also HomeSteadingToday.com. The latter of which started generating errors when he tried to prune and optimize the datatables driving his bulletin-board. A trivial task these days with tools such as vBulletin and/or phpMyAdmin.

Unfortunately a rogue spammer conjured up a situation reminiscent of Dante’s first circle of hell – pushing in email faster and before a scheduled disk-check job provided by the hosting company could run.

Meaning, because we didn’t get warnings, we were without a clue as to what and where the problem existed – a situation not only caused by spammers, but by rude residents for those of you on shared server solutions.
How is it I speak with such authority? Well a few months back, Chuck informed me at around 1am that he was having troubles, I issued the following MySQL directive:

repair table home_posts_text

The response was that wonderfully descriptive error message “28 when writing to datafile.” (Can you say ‘ubiquitous?’ … Sure … I knew you could).

After a quick visit to the ‘Rosetta Stone‘ that is otherwise known as groups.google.com, I putty’d back to my ssh session and entered the following directive from the command line:

df -h

Here is the response … with some of the names changed to protect the hackable. Note the 100% in bold: Filesystem Size Used Avail Use% Mounted on:

/dev/sda5 31G 30G 52M 100% /
/dev/sda1 99M 81M 13M 86% /boot
none 629M 0 629M 0% /dev/shm
/dev/sda3 289M 8.9M 264M 4% /tmp

One way to avoid this situation is to augment your hosting provider’s nightly solution with a ‘cron-able‘ script of your own. One that would will check that usage % with greater frequency than once a night … and instruct it to send everyone in the known universe an email when it gets close to the danger zone.

Before I re-invent the wheel, I’m looking for such a script … unless you already have or know of such a script, if so, then please, leave a comment.

2 Comments

  1. Well under Linux, you can simply have it email every night.

    Run “crontab -e” and add the lines

    MAILTO=you@yourdomain.com
    00 12 * * * df -h

    Another way to go is to set up SNMP on your Linux machine, which will let you monitor a huge amount of data such as CPU usage, disk busy %, swapping, network traffic, etc. Tools such as MRTG or rrdtool can be used to plot this information into nice graphs.

  2. Pingback: links for 2007-08-09 « geek notes