Monitor disk space usage

Monitor disk space usage

Monitor disk space usage

 

This script alerts you when the disk usage exceeds the percentage specified by the limit variable.

#!/bin/bash
### variables
# usage limit in procent; default 90%
limit=90
emailaddress="e-mail address where to send alert"
### code
usage=$(df / | grep / | awk '{print $5}' | sed 's/%//g')
dfoutput=$(df -h /)
if [ "$usage" -gt "$limit" ] ; then
    mail -s 'Disk Space Alert on '`hostname`' [ '$usage'% ].' $emailaddress << EOF
    $dfoutput
EOF
fi

You can put a link to this script in /etc/cron.daily folder, for daily verification, or as you need.

Monitor disk space usage




Monitor disk space usage

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close