Created
July 18, 2012 19:11
-
-
Save deekayen/3138161 to your computer and use it in GitHub Desktop.
Disk space cron monitor for Ubuntu
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 | |
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
Possible crontab to run hourly:
35 * * * * /usr/local/bin/df.sh