You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
1.1 KiB

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
## check disk usage and send a notification if it's above 75% or 90%
percent_usage=$(df /srv -h)
percent_usage=${percent_usage##*$'\n'}
percent_usage=${percent_usage% *}
percent_usage=${percent_usage##* }
percent_usage=${percent_usage%\%}
LOCK_WORKING_DIR="/var/run/myc-manage"
mkdir -p "$LOCK_WORKING_DIR"
if [ "$percent_usage" -ge "90" ]; then
if [ -e $LOCK_WORKING_DIR/disk_usage_90.lock ]; then
exit 0
else
touch $LOCK_WORKING_DIR/disk_usage_90.lock
message="$(hostname): WARNING disk usage >=90%"
send "disk_usage" "$message"
fi
elif [ "$percent_usage" -ge "75" ]; then
if [ -e $LOCK_WORKING_DIR/disk_usage_75.lock ]; then
exit 0
else
touch $LOCK_WORKING_DIR/disk_usage_75.lock
message="$(hostname): WARNING disk usage >=75 <90%"
send "disk_usage" "$message"
fi
else
if [ -e $LOCK_WORKING_DIR/disk_usage_75.lock ]; then
rm $LOCK_WORKING_DIR/disk_usage_75.lock
fi
if [ -e $LOCK_WORKING_DIR/disk_usage_90.lock ]; then
rm $LOCK_WORKING_DIR/disk_usage_90.lock
fi
fi