3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 # Checks that given_value is in range of correct_value +/- tolerance.
23 # Tolerance can be an absolute value or a percentage of the correct value
24 # (see examples with tolerances below).
25 # Outputs suitable message to stdout if it's not in range.
27 # A verbose option, -v, may be used as the LAST argument
30 # foo: 0.0298 = 0.03 +/- 5%
31 # _within_tolerance "foo" 0.0298 0.03 5%
33 # foo: 0.0298 = 0.03 +/- 0.01
34 # _within_tolerance "foo" 0.0298 0.03 0.01
36 # foo: 0.0298 = 0.03 -0.01 +0.002
37 # _within_tolerance "foo" 0.0298 0.03 0.01 0.002
39 # foo: verbose output of 0.0298 = 0.03 +/- 5%
40 # _within_tolerance "foo" 0.0298 0.03 5% -v
51 # maxtol arg is optional
52 # verbose arg is optional
64 [ "$6" = "-v" ] && _verbose=1
67 # find min with or without %
68 _mintolerance=`echo $_mintol | sed -e 's/%//'`
69 if [ $_mintol = $_mintolerance ]
71 _min=`echo "scale=5; $_correct_val-$_mintolerance" | bc`
73 _min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc`
76 # find max with or without %
77 _maxtolerance=`echo $_maxtol | sed -e 's/%//'`
78 if [ $_maxtol = $_maxtolerance ]
80 _max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc`
82 _max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc`
85 $_debug && echo "min = $_min"
86 $_debug && echo "max = $_max"
90 if ($_min <= $_given_val) 1;
91 if ($_min > $_given_val) 0;
96 if ($_given_val <= $_max) 1;
97 if ($_given_val > $_max) 0;
100 _above_min=`bc <$tmp.bc.1`
101 _below_max=`bc <$tmp.bc.2`
105 _in_range=`expr $_above_min \& $_below_max`
107 # fix up min, max precision for output
108 # can vary for 5.3, 6.2
109 _min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes
110 _max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes
112 if [ $_in_range -eq 1 ]
114 [ $_verbose -eq 1 ] && echo $_name is in range
117 [ $_verbose -eq 1 ] && echo $_name has value of $_given_val
118 [ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max
128 -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
131 # prints filtered output on stdout, values (use eval) on stderr
137 if (/^meta-data=([\w,|\/.-]+)\s+isize=(\d+)\s+agcount=(\d+), agsize=(\d+) blks/) {
138 print STDERR "ddev=$1\nisize=$2\nagcount=$3\nagsize=$4\n";
139 print STDOUT "meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks\n";
141 if (/^\s+=\s+sectsz=(\d+)\s+attr=(\d+)/) {
142 print STDERR "sectsz=$1\nattr=$2\n";
144 if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
145 print STDERR "dbsize=$1\ndblocks=$2\nimaxpct=$3\n";
146 print STDOUT "data = bsize=XXX blocks=XXX, imaxpct=PCT\n";
148 if (/^\s+=\s+sunit=(\d+)\s+swidth=(\d+) blks/) {
149 print STDERR "sunit=$1\nswidth=$2\nunwritten=1\n";
150 print STDOUT " = sunit=XXX swidth=XXX, unwritten=X\n";
152 if (/^naming\s+=version\s+(\d+)\s+bsize=(\d+)/) {
153 print STDERR "dirversion=$1\ndirbsize=$2\n";
154 print STDOUT "naming =VERN bsize=XXX\n";
156 if (/^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+),\s+version=(\d+)/ ||
157 /^log\s+=(internal log|[\w|\/.-]+)\s+bsize=(\d+)\s+blocks=(\d+)/) {
158 print STDERR "ldev=\"$1\"\nlbsize=$2\nlblocks=$3\nlversion=$4\n";
159 print STDOUT "log =LDEV bsize=XXX blocks=XXX\n";
161 if (/^\s+=\s+sectsz=(\d+)\s+sunit=(\d+) blks/) {
162 print STDERR "logsectsz=$1\nlogsunit=$2\n\n";
164 if (/^realtime\s+=([\w|\/.-]+)\s+extsz=(\d+)\s+blocks=(\d+), rtextents=(\d+)/) {
165 print STDERR "rtdev=$1\nrtextsz=$2\nrtblocks=$3\nrtextents=$4\n";
166 print STDOUT "realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX\n";
171 # prints the bits we care about in growfs
176 if (/^data\s+=\s+bsize=(\d+)\s+blocks=(\d+), imaxpct=(\d+)/) {
177 print "xfs_growfs --BlockSize=$1 --Blocks=$2\n";
187 /records in/ { next }
188 /records out/ { next }
189 /No space left on device/ { print " !!! disk full (expected)"
197 perl -ne 'if (/.*:(.*)/) {
198 if ( "$last_line" ne "$1" ) { print "$_"; $first_match=1; }
199 elsif ( $first_match==1 ) { print "*\n"; $first_match=0; }
203 print $_; $last_line=$_;
209 sed -e "s/[0-9/.]* [GMKiBbytes]*, [0-9]* ops\; [0-9/:. sec]* ([inf0-9/.]* [EPGMKiBbytes]*\/sec and [inf0-9/.]* ops\/sec)/XXX Bytes, X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/"
212 _filter_xfs_io_unique()
214 common_line_filter | _filter_xfs_io
217 # make sure this script returns success