3 # exercises pmie_check functionality
5 # Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 [ -f /etc
/gentoo-release
] && _notrun
"Gentoo is lacking chkconfig support"
17 [ -f /etc
/slackware-version
] && _notrun
"Slackware is lacking chkconfig support"
19 if [ -z "$PCP_PMIECONTROL_PATH" ]
21 echo "Error: botched installation - PCP_PMIECONTROL_PATH not defined"
29 _restore_config
$PCP_PMIECONTROL_PATH
30 _restore_config
$PCP_PMCDCONF_PATH
32 $sudo rm -rf $tmp.nogo
$tmp.locker
35 echo >>$here/$seq.full
36 echo "=== $file ===" >>$here/$seq.full
37 cat $file >>$here/$seq.full
42 status
=1 # failure is the default!
43 $sudo rm -f $tmp.
* $seq.full
44 signal
=$PCP_BINADM_DIR/pmsignal
46 trap "_cleanup; exit \$status" 0 1 2 3 15
48 lhost
=`hostname | sed -e 's/\..*//'`
50 remote
=`./getpmcdhosts -n 1 -L 2>$tmp.out`
51 rhost
=`echo $remote | sed -e 's/\..*//'`
52 [ -z "$remote" ] && _notrun
`cat $tmp.out`
54 # Now that we have pmmgr in the mix, there is more than one pmie
55 # potentially running, so lines like this
56 # ... try /var/lib/pcp/tmp/pmie/25453: different logfile, skip
57 # /var/log/pcp/pmmgr/bozo/pmie.log differs to /tmp/SEQ-PID.log1
58 # are now expected, and not a problem.
60 # mkdir: error lines ... not consistency in format, so cull 'em
61 # ditto for cd errors reported from pmie_check
66 -e "s/$seq-$$/SEQ-PID/g" \
67 -e "s;$PCP_BIN_DIR/pmie;\$PCP_BIN_DIR/pmie;" \
68 -e 's/line [0-9][0-9]*:/line N:/' \
70 -e 's/\([ "]\)'"$remote"'\([ "]\)/\1REMOTEHOST\2/g' \
71 -e 's/\([ "]\)'"$rhost"'\([ "]\)/\1REMOTEHOST\2/g' \
72 -e 's/\([ "]\)'"$host"'\([ "]\)/\1LOCALHOST\2/g' \
73 -e 's/\([ "]\)local:\([ "]\)/\1LOCALHOST\2/g' \
74 -e "s;/private/tmp;/tmp;g" \
75 -e '/ try .* different logfile, skip/d' \
76 -e '/\/pmmgr\/.* differs to /d' \
77 -e '/^.r[-w][-x]r[-w][-x]/s/.* \//... ls output ... /' \
79 -e '/\/pmie_check:.*cd:/d' \
82 -e 's/\.\.failed/failed (status=1)/' \
89 if [ -d $PCP_TMP_DIR/pmie
]
90 then cd $PCP_TMP_DIR/pmie
94 ls -l >>$here/$seq.full
96 echo "plist=$plist" >>$here/$seq.full
101 ps
-p $process >/dev
/null
2>&1
104 echo "urk, $PCP_TMP_DIR/pmie/$process has no running pmie instance"
106 count
=`expr $count + 1`
107 ps
-f -p $process >>$here/$seq.full
108 if `which pstree >/dev/null 2>&1`
110 pstree
$process >>$here/$seq.full
118 # create a basic pmcd config file
119 cat >$tmp.pmcd.conf
<< EOF
121 pmcd 2 dso pmcd_init pmda_pmcd.so
124 # create a pmie config file
125 cat >$tmp.conf
<< EOF
126 foo = sample.long.one;
127 doo = sample.long.ten;
130 # create pmie control files
131 cat >$tmp.control.v1.0
<< EOF
133 $remote n $tmp.log1 -c $tmp.conf
134 $remote n $tmp.log2 -c $tmp.conf
135 LOCALHOSTNAME n $tmp.log0 -c $tmp.conf
137 cat >$tmp.control.v1.1
<< EOF
139 $remote n n $tmp.log1 -c $tmp.conf
140 $remote n n $tmp.log2 -c $tmp.conf
141 LOCALHOSTNAME y n $tmp.log0 -c $tmp.conf
144 # real QA test starts here
145 _save_config
$PCP_PMIECONTROL_PATH
146 _save_config
$PCP_PMCDCONF_PATH
148 $sudo cp $tmp.pmcd.conf
$PCP_PMCDCONF_PATH
150 $sudo $signal -a -s TERM pmie
>/dev
/null
2>&1
152 _change_config pmcd on
153 _change_config pmie off
154 $sudo rm -f $PCP_TMP_DIR/pmie
/*
157 echo "pmie count at start of QA testing: $?"
160 echo === check default
install operation
===
161 _service pmie restart
2>&1 | _filter_pmie_start
163 # chkconfig no longer controls start-ability, expect non-zero
164 echo "pmie count after chkconfig pmie off: $?"
167 echo === check
for missing control
file ===
168 _change_config pmie off
169 $sudo rm -f $PCP_PMIECONTROL_PATH
170 _change_config pmie on
171 _service pmie restart
2>&1 | _filter_pmie_start | _filter
173 echo "pmie count after attempt without control file: $?"
176 echo === check pmie_check and custom configs
===
178 pmie_check
-V -V -N -c $tmp.control.v1.0
-l $tmp.log
179 cat $tmp.log | _filter
180 # don't bother counting pmie processes, as -N is used above!
184 pmie_check
-V -V -N -c $tmp.control.v1.1
-l $tmp.log
185 cat $tmp.log | _filter
186 # don't bother counting pmie processes, as -N is used above!
190 echo "=== warnings ... ==="
191 echo "--- stale lock file ---"
193 cat >$tmp.warning.
$case << EOF
195 LOCALHOSTNAME n n $tmp.locker/ok.$case -c $tmp.conf
198 touch -t `pmdate -35M %Y%m%d%H%M` $tmp.locker
/ok.
$case.lock
199 pmie_check
-V -V -N -c $tmp.warning.
$case -l $tmp.warning.
$case.log
200 cat $tmp.warning.
$case.log | _filter
202 echo "--- existing lock file ---"
203 case=`expr $case + 1`
204 cat >$tmp.warning.
$case << EOF
206 LOCALHOSTNAME n n $tmp.locker/ok.$case -c $tmp.conf
208 rm -f $tmp.locker
/ok.
$case.lock
209 touch $tmp.locker
/ok.
$case.lock
210 pmie_check
-V -V -N -c $tmp.warning.
$case -l $tmp.warning.
$case.log
211 cat $tmp.warning.
$case.log | _filter
213 echo "--- can't create lock file ---"
214 case=`expr $case + 1`
215 cat >$tmp.warning.
$case << EOF
217 LOCALHOSTNAME n n $tmp.locker/ok.$case -c $tmp.conf
219 chmod 555 $tmp.locker
220 pmie_check
-V -V -N -c $tmp.warning.
$case -l $tmp.warning.
$case.log
221 cat $tmp.warning.
$case.log | _filter
222 $sudo rm -rf $tmp.locker
224 echo "--- bad in-line shell commands ---"
225 case=`expr $case + 1`
226 cat >$tmp.warning.
$case << EOF
229 \$PATH=/some/where/bad:\$PATH
231 LOCALHOSTNAME n n $tmp.ok.$case -c $tmp.conf
233 pmie_check
-V -V -N -c $tmp.warning.
$case -l $tmp.warning.
$case.log
234 cat $tmp.warning.
$case.log | _filter
236 echo "--- missing \$version but really v1.1 ... original control.local issue ---"
237 case=`expr $case + 1`
238 cat >$tmp.warning.
$case << EOF
239 LOCALHOSTNAME n n $tmp.ok.$case -c $tmp.conf
241 pmie_check
-V -V -N -c $tmp.warning.
$case -l $tmp.warning.
$case.log
242 cat $tmp.warning.
$case.log | _filter
245 echo "=== errors ... ==="
246 echo "--- bad version ---"
248 cat >$tmp.error.
$case << EOF
250 LOCALHOSTNAME n $tmp.bad.$case -c $tmp.conf
252 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
253 cat $tmp.bad.
$case.log | _filter
255 case=`expr $case + 1`
256 echo "--- v1.0 socks != y|n ---"
257 cat >$tmp.error.
$case << EOF
259 LOCALHOSTNAME x $tmp.bad.$case -c $tmp.conf
261 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
262 cat $tmp.bad.
$case.log | _filter
264 case=`expr $case + 1`
265 echo "--- v1.1 socks != y|n ---"
266 cat >$tmp.error.
$case << EOF
268 LOCALHOSTNAME n x $tmp.bad.$case -c $tmp.conf
270 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
271 cat $tmp.bad.
$case.log | _filter
273 case=`expr $case + 1`
274 echo "--- v1.1 primary != y|n ---"
275 cat >$tmp.error.
$case << EOF
277 LOCALHOSTNAME x n $tmp.bad.$case -c $tmp.conf
279 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
280 cat $tmp.bad.
$case.log | _filter
282 case=`expr $case + 1`
283 echo "--- v1.0 insufficient fields ---"
284 cat >$tmp.error.
$case << EOF
286 LOCALHOSTNAME n $tmp.bad.$case
288 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
289 cat $tmp.bad.
$case.log | _filter
291 case=`expr $case + 1`
292 echo "--- v1.1 insufficient fields ---"
293 cat >$tmp.error.
$case << EOF
295 LOCALHOSTNAME n n $tmp.bad.$case
297 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
298 cat $tmp.bad.
$case.log | _filter
302 case=`expr $case + 1`
303 echo "--- can't create dir for logfile ---"
304 cat >$tmp.error.
$case << EOF
306 LOCALHOSTNAME n n $tmp.nogo/subdir/bad.$case -c $tmp.conf
308 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
309 cat $tmp.bad.
$case.log | _filter
311 case=`expr $case + 1`
312 echo "--- can't chdir to dir for logfile ---"
313 cat >$tmp.error.
$case << EOF
315 LOCALHOSTNAME n n $tmp.nogo/bad.$case -c $tmp.conf
317 pmie_check
-V -V -N -c $tmp.error.
$case -l $tmp.bad.
$case.log
318 cat $tmp.bad.
$case.log | _filter
320 $sudo rm -rf $tmp.nogo
322 _service pmie stop
2>&1 \
323 | _filter_pmie_start \
325 -e '/PMIE not running/d' \
326 -e '/pmie not running/d' \
328 _change_config pmie off