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

Skip to toolbar