Created
January 6, 2015 17:27
-
-
Save vegaasen/f7be1c2b2f4d629f8ba7 to your computer and use it in GitHub Desktop.
Simple disk free monitor shell script :-).
This file contains 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 | |
# | |
# @description Simple script which just checks the current state of a mount and then checks the volume for % used. If this % used is > treshold, then it will send an email. | |
# @author vegaasen | |
# @since 06.01.2015 | |
# @version 0.1-SNAPSHOT | |
# | |
THRESHOLD=95; | |
RECIPIENTS="[email protected]"; | |
PART=u01; | |
DATE=`date +"Date: %d.%m.%Y - %H:%M:%S"` | |
IN_USE=`df -h | egrep " " | grep "$PART" | awk '{ print $4 }' | cut -d'%' -f1`; | |
SERVER_NAME=`uname -n` | |
SUBJECT="$SERVER_NAME: Disk space warning"; | |
if [ $IN_USE -gt $THRESHOLD ]; then | |
echo -e "[INFO] The disk for \"$PART\" is above its highest threshold ($IN_USE% > $THRESHOLD%). Sending email to notify: \"$RECIPIENTS\"."; | |
echo -e "Subject: $SUBJECT\nDisk space warning. The diskspace used is above its threshold levels!\nServername: $SERVER_NAME\nDate sent: $DATE\nDiskspace threshold: $THRESHOLD%\nDiskspace in use: $IN_USE%\nPart: $PART" | sendmail "$RECIPIENTS"; | |
else | |
echo -e "$DATE\nCurrent state: OK\nCurrent diskspace-level: $IN_USE%\nCurrent threshold: $THRESHOLD%"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment