check_dsk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. #======================================================================
  3. # Disk Checker utility
  4. #
  5. # Simple little script that checks the status of all partitions
  6. # on a node's hard disks. It will produce a warning alert and list
  7. # the offending filesystems in nagios.
  8. #
  9. # Authors: SpEnTBoY
  10. # TheRocker
  11. #
  12. # Email: lonny@abyss.za.org
  13. # therocker@pawprints.2y.net
  14. #=====================================================================
  15. NUMBER=`rsh $1 -l root df -kP | grep -v ":" | grep -E "9[0-9]%" | tr -s ' '| cut -d' ' -f5 | cut -c1-2 | line`
  16. TMPFILE=/tmp/tmp.hndl
  17. TMPTOO=/tmp/two.hndl
  18. if [ "$NUMBER" -gt 90 ]
  19. then
  20. `rsh $1 -l root df -kP |grep -v ":" | grep -E "9[0-9]%" | tr -s ' '| cut -d' ' -f6,5 >> $TMPFILE`
  21. LINES=`wc -l /tmp/tmp.hndl | cut -c8`
  22. LINESCTL=`wc -l /tmp/tmp.hndl | cut -c8 `
  23. echo "Filesystems over 90% --> \c"
  24. #======================================================================
  25. # You'll see this one in a few our shell scripts. Just chcecking for
  26. # multiple occurances of the warnign condition. We gotta list 'em all
  27. #======================================================================
  28. while [ $LINESCTL != 0 ]
  29. do
  30. cat $TMPFILE | tail -$LINESCTL > $TMPTOO
  31. cat $TMPTOO > $TMPFILE
  32. LINESCTL=$(( $LINESCTL -1 ))
  33. LINES=$(( $LINES -1 ))
  34. DATA=`head -1 /tmp/tmp.hndl`
  35. echo "( $DATA ) \c"
  36. done
  37. echo "\n"
  38. #===============================================================
  39. # Clean up all those nasty tmp files that suck up valuable
  40. # disk realestate.
  41. #===============================================================
  42. rm -f $TMPFILE
  43. rm -f $TMPTOO
  44. exit 1
  45. else
  46. echo "No Filesystems over 90%... OK"
  47. exit 0
  48. fi