Last active
June 1, 2016 08:39
-
-
Save leihog/15b0c5c3ec48b6fa7ccc9aaca7fb887f to your computer and use it in GitHub Desktop.
Check disk space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAX=80 | |
[email protected] | |
HOST=`hostname` | |
DISKS=`df -h | awk -v max=$MAX 'NR>1 && NF>1 { perc = (NF==5) ? $4 : $5; sub("%","",perc); if (0+perc >= 0+max) print perc"%", $NF }'` | |
if [ "$DISKS" != "" ]; then | |
echo -e "Warning we are running out of disk space on $HOST \n$DISKS" | mail -s "Running out of disk space on $HOST" $EMAIL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment