Monitoring disk space in linux

Recently I ran into a situation where I need to monitor disk space on a couple servers while a code fix was being made. I needed to stop and start services when the disks got too full.

To do this I used a bash one liner loop to output information from the df command:

while :; do df; sleep 10; done

Sleeping for 10 seconds as to not thrash the disk horribly bad.

The disk free command gives you output similar to the following:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xvda1 8256952 4582112 3255412 59% /
udev 3806520 8 3806512 1% /dev
tmpfs 762928 180 762748 1% /run
none 5120 0 5120 0% /run/lock
none 3814624 0 3814624 0% /run/shm
/dev/xvdc 41276736 180236 38999760 1% /mnt

And thats it, you get to loop over the command you want until you hit ctrl-c to exit the loop.