Skip to content

Instantly share code, notes, and snippets.

@JPRuskin
Last active September 2, 2016 14:28
Show Gist options
  • Save JPRuskin/0b913cfab2b9215e2341 to your computer and use it in GitHub Desktop.
Save JPRuskin/0b913cfab2b9215e2341 to your computer and use it in GitHub Desktop.
E-mails a warning to the e-mail address when disk-usage on the main partition is over 90% ($threshold). Overwrites a log with the last runtime and usage stat. Requires SSMTP
#! /bin/bash
CURRENT=$(df / | grep / | awk '{ print $5 }' | sed 's/%//g')
THRESHOLD=90
LOGFILE=~/Scripts/DiskReport.log
echo "Last Run: $(date "+%d%m%Y %T") : $CURRENT% Used." > $LOGFILE
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
ssmtp -s 'Disk Space Alert' helpdesk@domain.tld << EOF
Root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment