Skip to content

Instantly share code, notes, and snippets.

@serverok
Created August 2, 2020 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save serverok/742cff757050f53d2e1615274f0eb10c to your computer and use it in GitHub Desktop.
Save serverok/742cff757050f53d2e1615274f0eb10c to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://serverok.in/bash-script-to-monitor-disk-usage
CURRENT_USAGE=$(df / | grep -v 'Filesystem' | awk '{print $5}' | sed 's/%//g')
ALERT_ON=80
if [ "$CURRENT_USAGE" -gt "$ALERT_ON" ] ; then
mail -s 'Disk Usage Warning' you@yourdomain.com << EOF
Disk almost full on / partition. Current Useage: $CURRENT_USAGE%
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment