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