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%\%} if [ "$percent_usage" -ge "90" ]; then if [ -e /tmp/disk_usage_90.lock ]; then exit 0 else touch /tmp/disk_usage_90.lock message="$(hostname): WARNING disk usage >=90%" send "disk_usage" "$message" fi elif [ "$percent_usage" -ge "75" ]; then if [ -e /tmp/disk_usage_75.lock ]; then exit 0 else touch /tmp/disk_usage_75.lock message="$(hostname): WARNING disk usage >=75 <90%" send "disk_usage" "$message" fi else if [ -e /tmp/disk_usage_75.lock ]; then rm /tmp/disk_usage_75.lock fi if [ -e /tmp/disk_usage_90.lock ]; then rm /tmp/disk_usage_90.lock fi fi