Last active
May 25, 2016 13:36
-
-
Save stefanotorresi/12302642c9548b61b2cce7a31985a374 to your computer and use it in GitHub Desktop.
check disk space left and send email warning
This file contains hidden or 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]" | |
# set alert-level % | |
ALERT=85 | |
MAILER=/usr/bin/mail | |
df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output; | |
do | |
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) | |
partition=$(echo $output | awk '{ print $2 }' ) | |
if [ $usep -ge $ALERT ]; then | |
echo "Space low on \"$partition ($usep%)\", on server $(hostname --fqdn) at $(date)" | | |
$MAILER -s "Alert: Free space low on $(hostname --fqdn):$partition" $ADMIN | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment