pmrep: update TODO, man page
[pcp.git] / qa / 578
blob76d11d61d89b893137b71a24786df9b24fcb85be
1 #! /bin/sh
2 # PCP QA Test No. 578
3 # Test for Bug #660497, change openfds metric to be the
4 # largest known file descriptor used by pmcd.
5 # This means the file descriptor can only ever increase.
6 # The following behaviour is expected:
7 # the file descriptor will increase when a client or pmda connects
8 # the file descriptor will stay the same when a client or pmda disconnects
10 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
13 seq=`basename $0`
14 echo "QA output created by $seq"
16 # get standard filters
17 . ./common.product
18 . ./common.filter
19 . ./common.check
21 rm -f $seq.out
22 if [ $PCP_VER -lt 30600 ]
23 then
24 ln $seq.out.1 $seq.out || exit 1
25 else
26 ln $seq.out.2 $seq.out || exit 1
29 status=1 # failure is the default!
30 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
31 rm -f $seq.full
33 signal=$PCP_BINADM_DIR/pmsignal
34 simple_domain=253
35 if [ -x pmobjstyle ]
36 then
37 style=`pmobjstyle`
38 else
39 style=''
42 _start_client()
44 pmval -T 10sec kernel.all.load >$tmp.tmp 2>&1 &
45 echo "=== Started client ===" | tee -a $here/$seq.full
46 sleep 3
49 # Remove the PMDA and restore pmcd.conf
51 _cleanup()
53 [ -f $PCP_PMDAS_DIR/simple/simple.conf.$seq ] && _restore_config $PCP_PMDAS_DIR/simple/simple.conf
55 if [ -f $PCP_PMCDCONF_PATH.$seq ]
56 then
57 echo "=== Resetting pmcd.conf back to original state ==="
58 _restore_config $PCP_PMCDCONF_PATH
59 _restore_config $PCP_VAR_DIR/pmns/root
60 echo "=== Restart PMCD ==="
61 unset PMCD_PORT
62 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
63 _wait_for_pmcd
66 if grep '^simple' $PCP_PMCDCONF_PATH >/dev/null
67 then
69 else
70 # simple was not installed, cull namespace
72 cd $PCP_PMDAS_DIR/simple
73 $sudo ./Remove >/dev/null
76 if [ -f $tmp.log ]
77 then
78 echo '=== pmcd log' >>$here/$seq.full
79 cat $tmp.log >>$here/$seq.full
82 rm -rf $tmp.*
85 trap "_cleanup; exit \$status" 0 1 2 3 15
87 _filter_ins()
89 sed \
90 -e 's/.* \(hash table entries\)/ NNN \1/' \
91 -e 's/.* \(non-leaf nodes\)/ NNN \1/' \
92 -e 's/.* \(leaf nodes\)/ NNN \1/' \
93 -e 's/.* \(bytes of symbol table\)/ NNN \1/'
96 _filter_init()
98 sed \
99 -e "s/$$/PID/g"
102 _filter_openfds_value()
104 $PCP_AWK_PROG '
105 BEGIN { fst_fds = "fst_fds"; sec_fds = "sec_fds"; thr_fds = "thr_fds"; step = 0 }
106 $1 == "value" && step == 0 {
107 fst_fds = $2; step = 1; next }
108 $1 == "value" && step == 1 {
109 sec_fds = $2; step = 2; next }
110 $1 == "value" && step == 2 {
111 thr_fds = $2;
112 if (sec_fds > fst_fds)
113 printf("=== Info: After install, openfds has increased as expected ===\n");
114 else {
115 printf("=== Error: After install, openfds has unexpectedly decreased or stayed the same ===\n");
116 printf("\t previous value %d, current value %d\n", fst_fds, sec_fds);
118 if (sec_fds == thr_fds)
119 printf("=== Info: After remove, openfds has stayed the same as expected ===\n");
120 else {
121 printf("=== Error: After remove, openfds has unexpectedly changed ===\n")
122 printf("\t previous value %d, current value %d\n", sec_fds, thr_fds);
124 next;
126 { next } '
129 # no random clients, thanks
131 port=`_get_port tcp 6060 6070`
132 if [ -z "$port" ]
133 then
134 echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
135 netstat -an
136 exit
138 PMCD_PORT=$port
139 export PMCD_PORT
141 # Build simple agent
143 echo "=== Building simple agent ===" | tee -a $here/$seq.full
144 unset ROOT TOOLROOT MAKEFLAGS
145 cd $PCP_PMDAS_DIR/simple
147 # get rid of warnings from simple if no config exists
148 [ -f simple.conf ] && _save_config simple.conf
149 echo "sec,min,hour" >$tmp.simple.conf
150 $sudo cp $tmp.simple.conf simple.conf
152 # Install the simple namespace, I don't bother to remove it again
154 $sudo ./Install -N < /dev/null | _filter_ins 2>&1
155 echo "Namespace installed"
157 if $sudo make > $tmp.make 2>&1
158 then
159 echo "PMDA built"
160 else
161 echo "Unable to build the simple PMDA:"
162 cat $tmp.make
163 exit
166 sed -e "/^@ SIMPLE/s/SIMPLE/$simple_domain/" < help \
167 | $sudo $PCP_BINADM_DIR/newhelp -v 2 -o help
168 echo "Help generated"
169 cd $here
171 # Refresh PMCD
173 _renew_pmcd()
175 echo "=== Restarting PMCD with minimal PMDAs ===" | tee -a $here/$seq.full
176 if [ -f $tmp.newconf ]
177 then
178 $sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
179 $sudo $signal -a -s HUP pmcd
180 sleep 4
181 _wait_for_pmcd
182 else
183 echo caller - $1 - has not created $tmp.newconf !!!
187 # Install a standard pmda, but do not mess with the namespace
189 _agent_install()
191 agent=$1
192 domain=$2
193 daemon=$3
194 path=$PCP_PMDAS_DIR/$agent
196 echo "=== Installing $agent ===" | tee -a $here/$seq.full
197 cp $tmp.newconf $tmp.latest
198 if $daemon
199 then
200 cat << end-of-file >> $tmp.latest
201 $agent $domain pipe binary $path/pmda$agent -d $domain
202 end-of-file
203 else
204 cat << end-of-file >> $tmp.latest
205 $agent $domain dso ${agent}_init $path/${style}pmda_$agent.$DSO_SUFFIX
206 end-of-file
209 $sudo cp $tmp.latest $PCP_PMCDCONF_PATH
211 $sudo $signal -a -s HUP pmcd
212 sleep 4
213 _wait_for_pmcd
215 if _check_agent $agent true
216 then
217 echo "$agent is alive and well"
218 else
219 echo "Failed to install $agent"
220 exit
224 # Remove a pmda
226 _agent_remove()
228 agent=$1
230 echo "=== Removing $agent ===" | tee -a $here/$seq.full
231 _renew_pmcd _agent_remove
233 if _check_agent $agent true
234 then
235 echo "Failed to remove $agent"
236 exit
237 else
238 echo "$agent was removed"
242 # real QA test starts here
244 # Copy and replace pmcd.conf
246 _save_config $PCP_PMCDCONF_PATH
247 _save_config $PCP_VAR_DIR/pmns/root
249 if [ $PCP_PLATFORM = linux ]
250 then
251 cat << end-of-file > $tmp.newconf
252 # pmcd.conf generated by QA $seq
253 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
254 linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
255 end-of-file
256 elif [ $PCP_PLATFORM = irix ]
257 then
258 cat << end-of-file > $tmp.newconf
259 # pmcd.conf generated by QA $seq
260 irix 1 dso irix_init libirixpmda.so
261 pmcd 2 dso pmcd_init pmda_pmcd.so
262 proc 3 dso proc_init pmda_proc.so
263 end-of-file
264 elif [ $PCP_PLATFORM = darwin ]
265 then
266 cat << end-of-file > $tmp.newconf
267 # pmcd.conf generated by QA $seq
268 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
269 darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
270 end-of-file
271 elif [ $PCP_PLATFORM = solaris ]
272 then
273 cat << end-of-file > $tmp.newconf
274 # pmcd.conf generated by QA $seq
275 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
276 solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
277 end-of-file
278 else
279 echo "Arrgh ... need pmcd.conf output for $PCP_PLATFORM"
280 exit 1
283 #_renew_pmcd main
285 if [ -f $tmp.newconf ]
286 then
287 $sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
290 # Start with a fresh pmcd log
292 # need to do this indirectly because system sudo cleanses the environment
294 echo "export PMCD_PORT=$PMCD_PORT" >$tmp.start
295 echo "$PCP_RC_DIR/pcp restart" >>$tmp.start
296 $sudo sh $tmp.start | _filter_pcp_start | _filter_init 2>&1
297 _wait_for_pmcd
299 _test_pmda()
301 pmda_type=$1
303 # Test PMDA
305 echo
306 echo "=== Testing PMDA as a $pmda_type ===" | tee -a $here/$seq.full
308 rm -f $tmp.pminfo
310 pminfo -f pmcd.openfds >$tmp.pminfo
311 fst_openfds=$openfds_value
313 if [ "$pmda_type" != PIPE ]
314 then
315 _agent_install simple $simple_domain false
316 else
317 _agent_install simple $simple_domain true
320 pminfo -f pmcd.openfds >>$tmp.pminfo
322 _agent_remove simple
323 pminfo -f pmcd.openfds >>$tmp.pminfo
325 echo "=== pminfo output ===" >>$here/$seq.full
326 cat $tmp.pminfo >>$here/$seq.full
328 cat $tmp.pminfo | _filter_openfds_value
330 echo "=== pmcd.log from _test_pmda ===" >>$here/$seq.full
331 cat $PCP_LOG_DIR/pmcd/pmcd.log >>$here/$seq.full
334 _test_client()
336 # Test a client
338 echo "=== Testing a Client ===" | tee -a $here/$seq.full
340 rm -f $tmp.pminfo
342 pminfo -f pmcd.openfds >$tmp.pminfo
344 _start_client
345 pminfo -f pmcd.openfds >>$tmp.pminfo
347 wait
348 pminfo -f pmcd.openfds >>$tmp.pminfo
350 echo "=== pmval output ===" >>$here/$seq.full
351 cat $tmp.tmp >>$here/$seq.full
352 echo "=== pminfo output ===" >>$here/$seq.full
353 cat $tmp.pminfo >>$here/$seq.full
355 cat $tmp.pminfo | _filter_openfds_value
357 echo "=== pmcd.log from _test_client ===" >>$here/$seq.full
358 cat $PCP_LOG_DIR/pmcd/pmcd.log >>$here/$seq.full
361 _test_client
362 _test_pmda DSO
363 _test_pmda PIPE
365 status=0
366 # success, all done
367 exit