A BASH script to monitor disk usage in Linux

Someone asked me if disk space usage can be monitored via a bash script. Yes, it can. The following script can be copied to the host to be monitored, then executed periodically (once an hour?) via a crontab. Keep in mind there are bigger better ways out there to do this, but this isn't bad for a small simple solution. It's also a good exercise for you if you are learning Linux!

#!/bin/bash
# A script to keep an eye on disk use. Mutt must be installed
# and the host must be able to send SMTP mail.

# Alert Recipient 
ADMIN="linux-admin@example.com" 

# Alert Threshhold
ALERT=85  

df -h -P | grep -vE '^Filesystem|tmpfs|cdrom|iso|nfs|140.139' | awk '{ print $5 " " $1 }' | while read OUTPUT;
do
        USAGE=$(echo $OUTPUT | awk '{ print $1 }' | cut -d'%' -f1 )
        PARTITION=$(echo $OUTPUT | awk '{ print $2 }')

        if [ $USAGE -ge $ALERT ] ; then
                echo -e "WARNING: Filesystem on \"$PARTITION\" is ${USAGE}% full.\n Threshold is 85% \n HOST: $HOSTNAME\nDATE: $(date)\nThis message generated by /admin-scripts/SpaceWatch on $HOSTNAME" | \
                mutt -s "Alert: Disk space warning on $HOSTNAME" ${ADMIN}
        fi

done

exit 0

2018 University of Nebraska Cornhuskers Football Schedule