Skip to content

Instantly share code, notes, and snippets.

@pce
Created January 21, 2014 12:20
Show Gist options
  • Select an option

  • Save pce/8539020 to your computer and use it in GitHub Desktop.

Select an option

Save pce/8539020 to your computer and use it in GitHub Desktop.
/usr/local/bin/space-checker
#!/bin/bash
# . .:free space checker:.
# -o-
# ' .-. .
# __/ @_\_ . * -o-
# (________) '
#
# * |
# . --o--
# . |
#
#
ADMIN="me@example.com"
ALERT=95
FREE=`df -Ph . | awk 'NR==2 {print $5}' | cut -d'%' -f1`
echo ${FREE}% free space on $(hostname).
if [[ $FREE -gt $ALERT ]]; then
SUBJECT="More than ${ALERT}% disk usage. ${FREE}% free space left."
echo $SUBJECT
echo "$(hostname) (/usr/local/bin/space-checker) : $SUBJECT" | mail -s "$SUBJECT" $ADMIN
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment