Skip to content

Instantly share code, notes, and snippets.

@albarki albarki/diskmon.sh forked from fduran/gist:1870429
Last active Jun 25, 2018

Embed
What would you like to do?
Linux disk space email alert
#!/bin/bash
# www.fduran.com
# script that will send an email to EMAIL when disk use in partition PART is bigger than %MAX
# adapt these 3 parameters to your case
MAX=95
EMAIL=alertemail@example.com,alteremail2@example.com
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
fi
@albarki

This comment has been minimized.

Copy link
Owner Author

albarki commented Jun 25, 2018

to install mail if it is not exist check here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.