Last active
September 2, 2016 14:28
-
-
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
This file contains hidden or 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 | |
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' [email protected] << 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