Friday, July 13, 2007

disk space report

Diskspace reporting is as easy as

# df
# df -ah
# df -vh

which would show you something like these

/dev/cciss/c0d0p2 4.8G 419M 4.1G 10% /
/dev/cciss/c0d0p1 97M 16M 76M 18% /boot
/dev/shm 252M 4.0K 252M 1% /dev/shm
/dev/cciss/c0d0p6 59G 26G 30G 47% /home
/dev/cciss/c0d0p7 3.8G 2.6G 1.1G 71% /usr
/dev/cciss/c0d0p5 62G 34G 25G 58% /var

If you are using LVM for spanning disk support, you might be seeing lines like these

Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p2 22G 12G 9.2G 56% /
/dev/cciss/c0d0p3 43G 32G 8.5G 80% /backup
/dev/cciss/c0d0p1 99M 20M 75M 21% /boot
/dev/mapper/VolGroup00_home-LogVol00_home 67G 14G 49G 22% /home
/dev/mapper/VolGroup00_var-LogVol00_var 67G 16G 47G 26% /var

Sending email via CLI was covered basically, so these data could be helpful to you when combined with shell scripts, that checks for certain harddisk capacity thresholds and alerts your group email via SMS/email if that specific unsafe threshholds were met. It could be accomplished using a combination of string manipulation and parsing linux commands inside a simple bash script.

Here is a basic shell script sample:

umask 077
df -vh | mail -s "My Server 1 Disk Space Report"

and add it to your cron like so

01 05 * * * /myscripts/diskspace

which sends email on daily basis.

Furthermore, you could create a script that spits out those numeric values where MRTG can chomp them and reflect them to your MRTG graph.



Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy