Skip to content

Instantly share code, notes, and snippets.

@gobinathm
Forked from deekayen/df.sh
Created July 10, 2013 14:21
Show Gist options
  • Save gobinathm/5966700 to your computer and use it in GitHub Desktop.
Save gobinathm/5966700 to your computer and use it in GitHub Desktop.
#!/bin/bash
ADMIN="help@example.com"
ALERT=95
df -H | grep -vE '^Filesystem|none|tmpfs|cdrom|varrun|varlock|udev|devshm|boot' | awk '{ print $4 " " $5 " " $6 }' | while read output;
do
usep=$(echo $output | awk '{ print $2}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $3 }' )
free=$(echo $output | awk '{ print $1 }' )
if [[ $usep -ge $ALERT ]]; then
echo "Running out of space $partition ($usep% used, $free avail)
on $(hostname) at $(date)" |
mail -s "Alert: Almost out of disk space $(hostname)" $ADMIN
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment