Watch disk space
Jump to navigation
Jump to search
Scriptas skirtas pranesti apie mazejancia disko vieta
#!/bin/bash
# Watch disk space by percent per mounted volume, and report if it exceeds the percentage that provided in this script configuration
# (c) 2018 justinas@eofnet.lt
DISK=/tmp # mount point to watch
PERCENT=90 # if disk is over 90 percentage then do the command
COMM="rm -f /tmp/*"
MAIL="justinas@eofnet.lt"
SPACE=`df -h $DISK|grep $DISK|awk '{print $5}'|awk -F\% '{print $1}'`
if [ "$SPACE" -ge "$PERCENT" ]; then
echo "Server status `hostname` $DISK space running low"|mail -n -s "Server status `hostname`" $MAIL
$COMM
fi