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

  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. LOCK_WORKING_DIR="/var/run/myc-manage"
  10. mkdir -p "$LOCK_WORKING_DIR"
  11. if [ "$percent_usage" -ge "90" ]; then
  12. if [ -e $LOCK_WORKING_DIR/disk_usage_90.lock ]; then
  13. exit 0
  14. else
  15. touch $LOCK_WORKING_DIR/disk_usage_90.lock
  16. message="$(hostname): WARNING disk usage >=90%"
  17. send "disk_usage" "$message"
  18. fi
  19. elif [ "$percent_usage" -ge "75" ]; then
  20. if [ -e $LOCK_WORKING_DIR/disk_usage_75.lock ]; then
  21. exit 0
  22. else
  23. touch $LOCK_WORKING_DIR/disk_usage_75.lock
  24. message="$(hostname): WARNING disk usage >=75 <90%"
  25. send "disk_usage" "$message"
  26. fi
  27. else
  28. if [ -e $LOCK_WORKING_DIR/disk_usage_75.lock ]; then
  29. rm $LOCK_WORKING_DIR/disk_usage_75.lock
  30. fi
  31. if [ -e $LOCK_WORKING_DIR/disk_usage_90.lock ]; then
  32. rm $LOCK_WORKING_DIR/disk_usage_90.lock
  33. fi
  34. fi