3 # Exercise iostat2pcp with locally installed iostat.
5 # Copyright (c) 2014 Red Hat.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 which iostat
>/dev
/null || _notrun
"No local iostat binary found"
17 # check iostat looks like right version
21 if iostat
-\? 2>&1 |
grep ".-[a-zA-Z]*$opt" >/dev
/null
25 _notrun
"installed iostat does not have a -$opt option"
29 which sar
>/dev
/null
2>&1 || _notrun
"sar not installed"
30 version
=`sar -V 2>&1 | sed -n -e '/sysstat version /{
37 _notrun
"sysstat version $version too old"
39 '') # not sysstat-based sar
40 _notrun
"sar not from sysstat package"
46 status
=1 # failure is the default!
47 $sudo rm -rf $tmp.
* $seq.full
48 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
52 echo "== Raw iostat:" >> $seq.full
57 BEGIN { cpucount=0; devcount=0; s=1.0 }
61 /^avg-cpu:/ { cpumode=1; cpucount++; next }
62 /^Device: *tps/ { tpsmode=1; devcount++; next }
63 /^Device:/ { devices=1; devcount++; next }
64 /^$/ { cpumode=0; tpsmode=0; devices=0; next }
65 { #print name-prefixed, and name-sorted output
66 if (cpumode == 1 && cpucount > 1) {
67 sample="'$f.
'"cpucount-1
68 printf "cpu.user %f\n", $1/100.0 >> sample
69 printf "cpu.nice %f\n", $2/100.0 >> sample
70 printf "cpu.sys %f\n", $3/100.0 >> sample
71 printf "cpu.wait.total %f\n", $4/100.0 >> sample
72 printf "cpu.steal %f\n", $5/100.0 >> sample
73 printf "cpu.idle %f\n", $6/100.0 >> sample
75 if (tpsmode == 1 && devcount > 1) {
76 sample="'$f.
'"devcount-1
78 printf "dev.total::%s %f\n", instance, $2 >> sample
79 printf "dev.read_bytes::%s %f\n", instance, $3*s >> sample
80 printf "dev.write_bytes::%s %f\n", instance, $4*s >> sample
82 if (devices == 1 && devcount > 1) {
83 sample="'$f.
'"devcount-1
85 s=0.5 # size scale - sectors vs kilobytes
86 printf "dev.read_merge::%s %f\n", instance, $2 >> sample
87 printf "dev.write_merge::%s %f\n", instance, $3 >> sample
88 printf "dev.read::%s %f\n", instance, $4 >> sample
89 printf "dev.write::%s %f\n", instance, $5 >> sample
90 printf "dev.read_bytes::%s %f\n", instance, $6*s >> sample
91 printf "dev.write_bytes::%s %f\n", instance, $7*s >> sample
92 printf "dev.avactive::%s %f\n", instance, $10 >> sample
94 printf "dev.read_rawactive::%s %f\n", instance, $11 >> sample
95 printf "dev.write_rawactive::%s %f\n", instance, $12 >> sample
100 result
=`echo $f.$sample | sed -e 's/.unsorted//g'`
101 sort -u < $f.
$sample > $result
103 echo "== Extracted iostat sample $sample" >> $seq.full
104 cat $result >> $seq.full
112 # extract two samples - just disk and cpu metrics, sorted
113 pminfo
-f -O+.0 -a $1 kernel disk
> $tmp.pminfo
.1
114 pminfo
-f -O-.1 -a $1 kernel disk
> $tmp.pminfo
.2
117 echo "== Raw pminfo sample $sample:" >> $seq.full
118 cat $tmp.pminfo.
$sample >> $seq.full
120 sed < $tmp.pminfo.
$sample \
122 -e 's/^kernel.all.//g' \
123 -e 's/"//g' -e 's/]//g' | \
125 /^[a-z]/ { metric=$1; next }
126 /^$/ { metric=""; next }
127 / value / { if (NF > 2) { printf "%s::%s %f\n", metric, $4, $6 }
128 if (NF == 2) { printf "%s %f\n", metric, $2 }
130 |
sort -u > $2.
$sample
132 echo "== Extracted pcp sample $sample:" >> $seq.full
133 cat $tmp.pcp.values.
$sample >> $seq.full
141 paste $1.
$sample $2.
$sample >$tmp.both
142 echo "== Merged $1.$sample and $2.$sample:" >> $seq.full
143 cat $tmp.both
>> $seq.full
145 echo Verifying sample
$sample
146 $PCP_AWK_PROG <$tmp.both
'
148 # within 2% is close enough to a match
149 if ($2/$4 > 1.002 || $2/$4 < 0.992)
150 print "[",NR,"] mismatch:",$1,$2,$4
154 # within 0.002 of zero is close enough to a match
156 print "[",NR,"] mismatch:",$1,$2,$4
160 # within 0.002 of zero is close enough to a match
162 print "[",NR,"] mismatch:",$1,$2,$4
168 # real QA test starts here
169 export S_TIME_FORMAT
=ISO
171 # three samples, one second apart (ignore first though)
172 iostat
-t 1 3 > $tmp.iostat
173 extract_iostat
$tmp.iostat
$tmp.iostat.values
175 echo "== Run iostat2pcp:" >> $seq.full
176 iostat2pcp
-v $tmp.iostat
$tmp.iostat2pcp
>> $seq.full
177 extract_pcp
$tmp.iostat2pcp
$tmp.pcp.values
179 echo "Comparing stock iostat output to PCP archive"
180 compare_samples
$tmp.iostat.values
$tmp.pcp.values
182 # compare the extended device stats next
183 iostat
-x -t 1 3 > $tmp.iostatx
184 extract_iostat
$tmp.iostatx
$tmp.iostatx.values
186 iostat2pcp
$tmp.iostatx
$tmp.iostatx2pcp
187 extract_pcp
$tmp.iostatx2pcp
$tmp.pcpx.values
189 echo "Comparing extended iostat output to PCP archive"
190 compare_samples
$tmp.iostatx.values
$tmp.pcpx.values