Created
June 12, 2015 09:58
-
-
Save r10r/7d9cc0399e354861138d to your computer and use it in GitHub Desktop.
E-Mail alert when disk usage exceeds a configured limit.
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 | |
LIMIT=95 | |
EMAIL=root | |
HEAD="$(df -h | head -n1)" | |
df -h | tail -n+2 | while read part | |
do | |
USED=`echo $part | awk '{ print $5 }' | cut -d'%' -f1` | |
if [ $USED -gt $LIMIT ]; then | |
name=$(echo $part | awk '{print $6}') | |
cat | mail -s "$(hostname): low disk space warning" $EMAIL <<EOF | |
Partition $name reached disk usage limit (${LIMIT}%) | |
$HEAD | |
$part | |
EOF | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
column
to align header and partition columns.