Last active
June 2, 2022 04:56
-
-
Save rjdp/bb1f2e46a146bb82e086e8b0a1d80c73 to your computer and use it in GitHub Desktop.
Disk Space monitoring
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='90' | |
DIR='/' | |
MAILTO='[email protected]' | |
SUBJECT="MySite disk usage reached above $LIMIT%" | |
MAILX='mailx' | |
which $MAILX > /dev/null 2>&1 | |
if ! [ $? -eq 0 ] | |
then | |
echo "Please install $MAILX" | |
exit 1 | |
fi | |
cd $DIR | |
USED=`df . | awk '{print $5}' | sed -ne 2p | cut -d"%" -f1` | |
if [ $USED -gt $LIMIT ] | |
then | |
df -h | $MAILX -s "$SUBJECT" "$MAILTO" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment