Last active
February 15, 2017 09:29
-
-
Save avtehnik/c7e39510067c207e70f5 to your computer and use it in GitHub Desktop.
check free space and send email if not enough
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
{ | |
"Data": "From: [email protected]\nTo: [email protected]\nSubject:Disk space filled up \nMIME-Version: 1.0\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\n\n--NextPart\nContent-Type: text/plain\n\nThis is the email to notify that the space in the disc for the server has reached the its maximum. Please, take an action concerning the old logs..\n\n--NextPart" | |
} |
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/sh | |
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; | |
do | |
echo $output | |
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) | |
partition=$(echo $output | awk '{ print $2 }' ) | |
if [ $usep -ge 90 ]; then | |
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" | | |
aws ses send-raw-email --raw-message file:///home/ubuntu/space-watcher/message.json --region=us-east-1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment