4 # pmie - lots of expressions, checking pmie -d output and %v binding
7 # Copyright (c) 2012 Ken McDonell. All Rights Reserved.
11 echo "QA output created by $seq"
13 # get standard filters
19 if [ $PCP_VER -lt 30702 ]
21 ln $seq.out
.1 $seq.out ||
exit 1
23 if [ $PCP_VER -lt 30900 ]
25 ln $seq.out
.2 $seq.out ||
exit 1
27 ln $seq.out
.3 $seq.out ||
exit 1
31 status
=1 # failure is the default!
32 $sudo rm -rf $tmp.
* $seq.full
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
40 # same syslog options for Irix, Linux and OpenSolaris
41 SYSLOG_OPT
='"-p daemon.info"'
47 echo "Arrgh ... need syslog option for $PCP_PLATFORM"
52 # may be using journalctl, and so no syslog in the file system
54 if `which journalctl >/dev/null 2>&1`
56 echo "Using journalctl ..." >>$seq.full
61 for f
in /var
/adm
/SYSLOG
/var
/log
/daemon.log
/var
/log
/messages
/var
/log
/syslog
/var
/log
/system.log
71 echo "Arrgh! Cannot find your syslog file"
79 -e "s/\([:@ ]\)$LOCALHOST/\1LOCALHOST/g" \
80 -e "s/\([:@ ]\)local:/\1LOCALHOST/g" \
81 -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]/DATE/' \
82 -e 's/DATE [12][0-9][0-9][0-9]/DATE/' \
83 -e '/evaluator exiting/s/pmie([0-9][0-9]*)/pmie(PID)/' \
84 -e '/Performance Co-Pilot Inference Engine/s/Version .*/Version .../' \
85 -e 's/\[red] 1[0-9][0-9]/[red] >=100/' \
86 -e 's/\[green] 2[0-9][0-9]/[green] >=200/' \
87 -e 's/\[blue] 3[0-9][0-9]/[blue] >=300/'
93 $1 == "pmie:" { print; next }
94 /failed: / { print; next }
95 $1 == "initMetric:" { skip=1 }
96 skip == 1 { if ($1 == "Rule:") skip = 0 }
99 tr ' =' '\012' <$tmp.tmp \
101 |
$PCP_AWK_PROG >$tmp.
sed '
103 { if (seen[$1] == 1) next
104 printf "s/%s/ADDR%03d/\n",$1,n
108 sed -f $tmp.
sed <$tmp.tmp
111 cat <<End-of-File >$tmp.pmie
112 some_inst sample.part_bin > 500 -> print "some > 500:" " [%i] %v";
113 all_inst sample.part_bin > 0 -> shell "echo 'all > 0:'" " [%i] %v";
114 some_sample hinv.ncpu @0..2 == hinv.ncpu -> syslog 10sec $SYSLOG_OPT "PCP QA $seq - please ignore: some sample ncpu equal" " [%i] %v";
115 ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "arith %v";
117 sample.long.one != 2 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean1 %v";
119 sample.long.one <= 0 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean2 %v";
121 sample.long.one < 9 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean3 %v";
123 sample.long.one < 1 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean4 %v";
124 // pmns error || true
125 min_inst no_such_metric == 100 || sample.long.million > 0 -> print "error1 %v";
127 min_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean5:" " [%i] %v";
129 // NOTE instance bindings here will be for the _left_ subexpression
130 // (which is always false) ... this is odd but not unexpected
131 max_inst sample.part_bin == 100 || ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean6:" " [%i] %v";
133 sum_inst sample.part_bin > 500 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean7:" " [%i] %v";
135 avg_inst(sample.part_bin) == 0 || ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean8:" " [%i] %v";
136 count_inst(sample.part_bin > 0) > 0 -> print "count_inst:" "[%i] %v";
137 some_inst match_inst "bin-[12345]" sample.part_bin > 100 -> print "match_inst:" " [%i] %v";
138 some_inst nomatch_inst "bin-[12345]" sample.part_bin > 200 -> print "nomatch_inst:" " [%i] %v";
139 // rising, falling - see QA 515
140 all_inst rate sample.bin == 0 -> print "rate:" " [%i] %v";
141 66%_inst sample.colour >= 200 -> print "66%_inst:" " [%i] %v";
142 all_sample sample.long.ten @0..2 == 10 -> print "all_sample: " " [%i] %v";
143 60%_sample some_inst sample.part_bin #'bin-300' #'bin-500' #'bin-700' @0..1 >= 500 -> print "60%_sample: " " [%i] %v";
144 min_sample sample.long.hundred @0..1 == 100 -> print "min_sample: " " [%i] %v";
145 max_sample sample.long.hundred @0..1 == 100 -> print "max_sample: " " [%i] %v";
146 sum_sample sample.bin #'bin-100' @0..3 == 400 -> print "sum_sample: " " [%i] %v";
147 avg_sample sample.bin #'bin-200' @0..1 == 200 -> print "avg_sample: " " [%i] %v";
148 count_sample(some_inst sample.bin #'bin-200' #'bin-300' #'bin-400' @0..2 == 300) == 3 -> print "count_sample: " " [%i] %v";
149 min_inst sample.part_bin > 0 -> print "min_inst:" " @%h [%i] %v";
150 max_inst sample.part_bin > 0 -> print "max_inst:" " @%h [%i] %v";
151 sample.long.one == 1 -> shell "false" | print "false |: %v";
152 sample.long.ten == 10 -> shell "true" & print "true &: %v";
153 sample.long.hundred == 100 -> print "print |:" " %v" | print "bozo don't execute me!";
155 // TODO at some other time ... alarm and stomp actions
158 # real QA test starts here
159 cat <<End-of-File | pmie -t 250msec -d -Dappl1 >$tmp.out 2>$tmp.err &
169 echo "pmie PID $!" >>$seq.full
171 echo "=== pmie output ===" >>$seq.full
172 cat $tmp.out
>>$seq.full
174 echo "=== pmie errors ===" >>$seq.full
175 cat $tmp.err
>>$seq.full
177 _filter2
<$tmp.err | _filter
184 # be careful ... --boot not supported in all versions, -l not
185 # supported in all versions
186 $sudo journalctl
-b --full |
tail -100 >$tmp.syslog
188 $sudo tail -100 $SYSLOG >$tmp.syslog
190 sed <$tmp.syslog
-n \
191 -e 's/PCP QA '"$seq"'/PCP QA xxx/' \
192 -e '/ncpu equal/s/ [0-9][0-9]*/ N/g' \
193 -e 's/PCP QA xxx/PCP QA '"$seq"'/' \
194 -e '/\['$
!']: PCP QA '"$seq"' - please ignore/{
195 s/.*please ignore/.../
198 | LC_COLLATE
=POSIX
sort -u
203 echo "=== tail journalctl -b --full ===" >>$seq.full
205 echo "=== tail SYSLOG ($SYSLOG) ===" >>$seq.full
207 echo "`wc -l <$tmp.syslog | sed -e 's/ //g'` lines ... expect 100" >>$seq.full
208 cat $tmp.syslog
>>$seq.full