check_io 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #! /bin/sh
  2. #=================================================================
  3. #
  4. # I/O Checker (KBPS)
  5. # This Script uses iostat to monitor disk io
  6. # Useful for notifications of disk thrashing.
  7. #
  8. # Authors: TheRocker
  9. # SpEnTBoY
  10. #
  11. # Email: therocker@pawprints.2y.net
  12. # lonny@abyss.za.org
  13. #
  14. #================================================================
  15. NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line`
  16. NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line`
  17. TMPFILE=/tmp/iotest.hndl
  18. TMPTOO=/tmp/iotwo.hndl
  19. #===========================================================
  20. #
  21. # We do an evaluation on $NUMBER1 and $NUMBER2 to see if
  22. # disk io is exceeding 40%.
  23. #
  24. #===========================================================
  25. if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ]
  26. then
  27. `rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE`
  28. #====================================================================
  29. #
  30. # Of course, there may be more than one hard disk on the node
  31. # so we use this bit of code to report on more than one instance
  32. # of excessive disk IO.
  33. #
  34. #====================================================================
  35. LINES=`wc -l /tmp/iotest.hndl | cut -c8`
  36. LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 `
  37. echo "WARNING!!! Disk I/O Exceeding 40% on --> \c"
  38. while [ $LINESCTL != 0 ]
  39. do
  40. cat $TMPFILE | tail -$LINESCTL > $TMPTOO
  41. cat $TMPTOO > $TMPFILE
  42. LINESCTL=$(( $LINESCTL -1 ))
  43. LINES=$(( $LINES -1 ))
  44. DATA=`head -1 /tmp/iotest.hndl`
  45. echo "( $DATA ) "
  46. done
  47. echo "\n"
  48. rm -f $TMPFILE
  49. rm -f $TMPTOO
  50. exit 1
  51. else
  52. print "No Disk I/O Exceeding 40%...OK"
  53. exit 0
  54. fi