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.

35 lines
970 B

  1. SHELL=/bin/bash
  2. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  3. ## check disk usage and send a notification if it's above 75% or 90%
  4. percent_usage=$(df /srv -h)
  5. percent_usage=${percent_usage##*$'\n'}
  6. percent_usage=${percent_usage% *}
  7. percent_usage=${percent_usage##* }
  8. percent_usage=${percent_usage%\%}
  9. if [ "$percent_usage" -ge "90" ]; then
  10. if [ -e /tmp/disk_usage_90.lock ]; then
  11. exit 0
  12. else
  13. touch /tmp/disk_usage_90.lock
  14. message="$(hostname): WARNING disk usage >=90%"
  15. send "disk_usage" "$message"
  16. fi
  17. elif [ "$percent_usage" -ge "75" ]; then
  18. if [ -e /tmp/disk_usage_75.lock ]; then
  19. exit 0
  20. else
  21. touch /tmp/disk_usage_75.lock
  22. message="$(hostname): WARNING disk usage >=75 <90%"
  23. send "disk_usage" "$message"
  24. fi
  25. else
  26. if [ -e /tmp/disk_usage_75.lock ]; then
  27. rm /tmp/disk_usage_75.lock
  28. fi
  29. if [ -e /tmp/disk_usage_90.lock ]; then
  30. rm /tmp/disk_usage_90.lock
  31. fi
  32. fi