Quick and dirty way to get an alert before your server starts to go crazy because of a full disk.

This script checks if a disk is more than 75% full.


df -h | awk '/%/ {
        limit = 75
        percent = sprintf("%d",$5)
        if ( percent > limit ) {
                print "Warning: ",$6," (",$1,") is to ",percent,"% full:"
                print $0

Save it under /root/ and create the following crontab entry to check the disk usage every day at half past midnight.

30  0  *   *   *     /root/

Assuming your host has configured an MTA and defined a recipient for root@<yourhost>, you should get an e-mail whenever a disk is more than 75% full.

blog comments powered by Disqus