Skip to content

Instantly share code, notes, and snippets.

@rjdp
Last active June 2, 2022 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjdp/bb1f2e46a146bb82e086e8b0a1d80c73 to your computer and use it in GitHub Desktop.
Save rjdp/bb1f2e46a146bb82e086e8b0a1d80c73 to your computer and use it in GitHub Desktop.
Disk Space monitoring
#!/bin/bash
LIMIT='90'
DIR='/'
MAILTO='user@gmail.com'
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