summaryrefslogtreecommitdiffstats
path: root/contrib/aix/check_io
blob: 58b25f6ddbd987a367fc393d75da47575d3acc0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh

#=================================================================
#
#  I/O Checker (KBPS)
#  This Script uses iostat to monitor disk io
#  Useful for notifications of disk thrashing.
#
#    Authors:  TheRocker
#              SpEnTBoY
#
#    Email:    therocker@pawprints.2y.net
#              lonny@abyss.za.org
#
#================================================================

NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line`
NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line`
TMPFILE=/tmp/iotest.hndl
TMPTOO=/tmp/iotwo.hndl

#===========================================================
#
#  We do an evaluation on $NUMBER1 and $NUMBER2 to see if
#  disk io is exceeding 40%.
#
#===========================================================

if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ]
then

 `rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE`

#====================================================================
#
#  Of course, there may be more than one hard disk on the node
#  so we use this bit of code to report on more than one instance
#  of excessive disk IO.
#
#====================================================================

     LINES=`wc -l /tmp/iotest.hndl | cut -c8`
     LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 `
     echo "WARNING!!! Disk I/O Exceeding 40% on --> \c" 
     
     while [ $LINESCTL != 0 ]
      do

       cat $TMPFILE | tail -$LINESCTL > $TMPTOO
       cat $TMPTOO > $TMPFILE
       LINESCTL=$(( $LINESCTL -1 ))
       LINES=$(( $LINES -1 ))
       DATA=`head -1 /tmp/iotest.hndl`
       echo "( $DATA ) "
       
     
     done
     echo "\n"

     rm -f $TMPFILE
     rm -f $TMPTOO
     exit 1 

else   

   print "No Disk I/O Exceeding 40%...OK"
   exit 0

fi