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
18 status
=1 # failure is the default!
19 $sudo rm -rf $tmp.
* $seq.full
20 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
27 # same syslog options for Linux and OpenSolaris
28 SYSLOG_OPT
='"-p daemon.info"'
34 echo "Arrgh ... need syslog option for $PCP_PLATFORM"
39 # may be using journalctl, and so no syslog in the file system
41 if `which journalctl >/dev/null 2>&1`
43 echo "Using journalctl ..." >>$seq.full
48 for f
in /var
/adm
/SYSLOG
/var
/log
/daemon.log
/var
/log
/messages
/var
/log
/syslog
/var
/log
/system.log
58 echo "Arrgh! Cannot find your syslog file"
66 -e "s/\([:@ ]\)$LOCALHOST/\1LOCALHOST/g" \
67 -e "s/\([:@ ]\)local:/\1LOCALHOST/g" \
68 -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/' \
69 -e 's/DATE [12][0-9][0-9][0-9]/DATE/' \
70 -e '/evaluator exiting/s/pmie([0-9][0-9]*)/pmie(PID)/' \
71 -e '/Performance Co-Pilot Inference Engine/s/Version .*/Version .../' \
72 -e 's/\[red] 1[0-9][0-9]/[red] >=100/' \
73 -e 's/\[green] 2[0-9][0-9]/[green] >=200/' \
74 -e 's/\[blue] 3[0-9][0-9]/[blue] >=300/' \
75 -e 's/level=[0-9][0-9]* tag=/level=N tag=/' \
79 # mapping to 0x0 -> (nil) needed for C compilers that don't do the
80 # (nil) translation automatically for a printf %p
85 -e 's/0x0\([ (]\)/(nil)\1/g' \
88 $1 == "pmie:" { print; next }
89 /failed: / { print; next }
90 $1 == "initMetric:" { skip=1 }
91 skip == 1 { if ($1 == "Rule:") skip = 0 }
94 tr ' =' '\012' <$tmp.tmp \
96 |
$PCP_AWK_PROG >$tmp.
sed '
98 { if (seen[$1] == 1) next
99 printf "s/%s/ADDR%03d/\n",$1,n
103 sed -f $tmp.
sed <$tmp.tmp
106 cat <<End-of-File >$tmp.pmie
107 some_inst sample.part_bin > 500 -> print "some > 500:" " [%i] %v";
108 all_inst sample.part_bin > 0 -> shell "echo 'all > 0:'" " [%i] %v";
109 some_sample hinv.ncpu @0..2 == hinv.ncpu -> syslog 10sec $SYSLOG_OPT "PCP QA $seq - please ignore: some sample ncpu equal" " [%i] %v";
110 ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "arith %v";
112 sample.long.one != 2 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean1 %v";
114 sample.long.one <= 0 && ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean2 %v";
116 sample.long.one < 9 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean3 %v";
118 sample.long.one < 1 && ! ( sample.long.million + sample.long.one - sample.long.ten ) * sample.long.hundred / sample.long.ten >= 0 -> print "boolean4 %v";
119 // pmns error || true
120 min_inst no_such_metric == 100 || sample.long.million > 0 -> print "error1 %v";
122 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";
124 // NOTE instance bindings here will be for the _left_ subexpression
125 // (which is always false) ... this is odd but not unexpected
126 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";
128 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";
130 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";
131 count_inst(sample.part_bin > 0) > 0 -> print "count_inst:" "[%i] %v";
132 some_inst match_inst "bin-[12345]" sample.part_bin > 100 -> print "match_inst:" " [%i] %v";
133 some_inst nomatch_inst "bin-[12345]" sample.part_bin > 200 -> print "nomatch_inst:" " [%i] %v";
134 // rising, falling - see QA 515
135 all_inst rate sample.bin == 0 -> print "rate:" " [%i] %v";
136 66%_inst sample.colour >= 200 -> print "66%_inst:" " [%i] %v";
137 all_sample sample.long.ten @0..2 == 10 -> print "all_sample: " " [%i] %v";
138 60%_sample some_inst sample.part_bin #'bin-300' #'bin-500' #'bin-700' @0..1 >= 500 -> print "60%_sample: " " [%i] %v";
139 min_sample sample.long.hundred @0..1 == 100 -> print "min_sample: " " [%i] %v";
140 max_sample sample.long.hundred @0..1 == 100 -> print "max_sample: " " [%i] %v";
141 sum_sample sample.bin #'bin-100' @0..3 == 400 -> print "sum_sample: " " [%i] %v";
142 avg_sample sample.bin #'bin-200' @0..1 == 200 -> print "avg_sample: " " [%i] %v";
143 count_sample(some_inst sample.bin #'bin-200' #'bin-300' #'bin-400' @0..2 == 300) == 3 -> print "count_sample: " " [%i] %v";
144 min_inst sample.part_bin > 0 -> print "min_inst:" " @%h [%i] %v";
145 max_inst sample.part_bin > 0 -> print "max_inst:" " @%h [%i] %v";
146 sample.long.one == 1 -> shell "false" | print "false |: %v";
147 sample.long.ten == 10 -> shell "true" & print "true &: %v";
148 sample.long.hundred == 100 -> print "print |:" " %v" | print "bozo don't execute me!";
150 // TODO at some other time ... alarm and stomp actions
153 # real QA test starts here
154 cat <<End-of-File | pmie -t 250msec -d -Dappl1 >$tmp.out 2>$tmp.err &
163 # strange but true ... sometimes don't need an echo here to deal
164 # with the pmie> (and no newline) prompt ...
178 echo "pmie PID $!" >>$seq.full
180 echo "=== pmie output ===" >>$seq.full
181 cat $tmp.out
>>$seq.full
183 echo "=== pmie errors ===" >>$seq.full
184 cat $tmp.err
>>$seq.full
186 _filter2
<$tmp.err | _filter
192 # be careful ... --boot not supported in all versions, -l not
193 # supported in all versions
194 $sudo journalctl
-b --full |
tail -100 >$tmp.syslog
196 $sudo tail -100 $SYSLOG >$tmp.syslog
198 sed <$tmp.syslog
-n \
199 -e 's/PCP QA '"$seq"'/PCP QA xxx/' \
200 -e '/ncpu equal/s/ [0-9][0-9]*/ N/g' \
201 -e 's/PCP QA xxx/PCP QA '"$seq"'/' \
202 -e '/\['$
!']: PCP QA '"$seq"' - please ignore/{
203 s/.*please ignore/.../
206 | LC_COLLATE
=POSIX
sort -u
211 echo "=== tail journalctl -b --full ===" >>$seq.full
213 echo "=== tail SYSLOG ($SYSLOG) ===" >>$seq.full
215 echo "`wc -l <$tmp.syslog | sed -e 's/ //g'` lines ... expect 100" >>$seq.full
216 cat $tmp.syslog
>>$seq.full