-
-
Save anjilinux/314d13e951ac8262b44dbe6f0077de3f to your computer and use it in GitHub Desktop.
Check disk space, send email when low. Put this in a cron job.
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/sh | |
| EMAILS=foo@example.com bar@example.com | |
| 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 ) | |
| parition=$(echo $output | awk '{ print $2 }' ) | |
| if [ $usep -ge 75 ]; then | |
| echo "Disk space low for \"$partition ($usep%)\" on $(hostname) as of $(date)" | mail -s "Alert: Low disk space $usep%" $EMAILS | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment