Created
July 18, 2012 19:10
-
-
Save deekayen/3138155 to your computer and use it in GitHub Desktop.
Disk space cron monitor for Ubuntu 8.04
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="[email protected]" | |
ALERT=95 | |
df -H | grep -vE '^Filesystem|tmpfs|cdrom|varrun|varlock|udev|devshm|boot' | awk '{ print $3 " " $4 " " $5 }' | 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