Skip to content

Instantly share code, notes, and snippets.

@c0bra
Created July 16, 2014 16:20
Show Gist options
  • Select an option

  • Save c0bra/d2bfefd0b58a960fcaf3 to your computer and use it in GitHub Desktop.

Select an option

Save c0bra/d2bfefd0b58a960fcaf3 to your computer and use it in GitHub Desktop.
ADMIN="your-email@you.com"
# set alert level 90% is default
ALERT=90
df -H | grep -vE '^Filesystem|tmpfs|cdrom|^//|/mnt' | awk '{ print $5 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "ALERT: Almost out of disk space $usep" $ADMIN
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment