check_crit_dsk 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. #=========================================================================
  3. # Critical Disk Checker utility
  4. #
  5. # This is the same as the disk checker utility but we use it as
  6. # a seperate service in Nagios to report on partitions that
  7. # have reached 100% capacity.
  8. #
  9. # We have excluded /dev/cd0 because the cdrom drive will always
  10. # report 100% capacity if a CD is in the drive.
  11. #
  12. # Authors: TheRocker
  13. # SpEnTBoY
  14. #
  15. # Email: therocker@pawprints.2y.net
  16. # lonny@abyss.za.org
  17. #
  18. #=======================================================================
  19. NUMBER=`rsh $1 -l root df -kP | grep -vE ":|/dev/cd0" | grep -E "100%" | tr -s ' '| cut -d' ' -f5 | cut -c1-3 | line`
  20. TMPFILE=/tmp/tmpcrit.hndl
  21. TMPTOO=/tmp/twocrit.hndl
  22. if [ "$NUMBER" -eq 100 ]
  23. then
  24. `rsh $1 -l root df -kP |grep -vE ":|/dev/cd0" | grep -E "100%" | tr -s ' '| cut -d' ' -f6,5 >> $TMPFILE`
  25. LINES=`wc -l /tmp/tmpcrit.hndl | cut -c8`
  26. LINESCTL=`wc -l /tmp/tmpcrit.hndl | cut -c8 `
  27. echo "Filesystems over 99% --> \c"
  28. #===============================================================
  29. # Just a little bit to check for multiple occurances of the
  30. # condition.
  31. #===============================================================
  32. while [ $LINESCTL != 0 ]
  33. do
  34. cat $TMPFILE | tail -$LINESCTL > $TMPTOO
  35. cat $TMPTOO > $TMPFILE
  36. LINESCTL=$(( $LINESCTL -1 ))
  37. LINES=$(( $LINES -1 ))
  38. DATA=`head -1 /tmp/tmpcrit.hndl`
  39. echo "( $DATA ) \c"
  40. done
  41. echo "\n"
  42. #===============================================================
  43. # File clean up. Always pick up after yourself. Disk space
  44. # doesn't grow on trees you know.
  45. #===============================================================
  46. rm -f $TMPFILE
  47. rm -f $TMPTOO
  48. exit 2
  49. else
  50. echo "No Filesystems over 99%... OK"
  51. exit 0
  52. fi