3 # PMCD SIGHUP processing tests with $PCP_PMCDCONF_PATH changes
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard filters
19 ln $seq.out.ipv6
$seq.out ||
exit 1
21 ln $seq.out.nonipv6
$seq.out ||
exit 1
27 _filter_pmcd_log
<.
/pmcd.log \
29 -e '/^DATA: from client/d' \
30 -e '/cmd=.*pmdasample/s//cmd=...pmdasample/' \
32 -e 's/Cannot open 000000660066: No such file or directory//' \
36 s/\[[0-9][0-9]*]/[PID]/
39 -e '/_pmHaveMoreInput/{
40 s/\[[0-9][0-9]*]/[PID]/
41 s/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/
44 s/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/
47 -e '/pmXmitPDU/s/\[[0-9][0-9]*]/[PID]/' \
48 -e '/pmResult/s/ .* numpmid/ ... numpmid/' \
50 s/value [0-9][0-9]*/value INTEGER/
52 -e 's;pcp/lib/mips_[^.]*\.;pcp/lib/ISA.;' \
53 -e '/access violation from host/d' \
54 -e '/endclient client.* No permission/d' \
55 -e 's/fd=[0-9][0-9]*/fd=FD/g' \
56 -e "/sed: couldn't flush stdout: Broken pipe/d" \
57 -e '/UNIX_DOMAIN_SOCKET/d' \
60 $3 ~ /^[0-9][0-9]*$/ { $3 = "A_PID" }
61 $1 == "news" { $4 = "fd_in"; $5 = "fd_out" }
62 $1 == "cisco" { $4 = "fd_in"; $5 = "fd_out"
63 for (i = 9; i <= NF; i++) {
64 # cull args like wanfoo:s0 or wanbar:e1
65 if ($i ~ /:[a-z]/) $i = ""
68 /pipe cmd=/ { $4 = "FD"; $5 = "FD" }
69 /Host access list:/ { localHostPrinted = 0 }
70 /localhost/ { if (! localHostPrinted) {
72 sub(/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/,"MYIPADDR",$5)
73 sub(/^[0-9a-f:][0-9a-f:]*%[0-9a-z]+$/,"MYIPADDR",$5)
74 sub(/^[0-9a-f:][0-9a-f:]*$/,"MYIPADDR",$5)
75 sub(/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/,"MYHOSTMASK",$6)
76 sub(/^[0-9a-f:][0-9a-f:]*$/,"MYHOSTMASK",$6)
81 | _filter_optional_pmdas \
87 -e '/Cleanup "fake_linux" agent (dom 60): unconfigured/q'
90 CONFIG
=$PCP_PMCDCONF_PATH
91 NEWCONFIG
=$tmp/pmcd.conf
92 CONFIGSAVE
=$tmp/pmcd.conf.save
93 [ -z "$PCP_PMLOGGERCONTROL_PATH" ] && \
94 PCP_PMLOGGERCONTROL_PATH
="$PCP_SYSCONF_DIR/pmlogger/control"
95 LOGCONTROL
=$PCP_PMLOGGERCONTROL_PATH
96 SAVE_LOGCONTROL
=$tmp/control.save
97 signal
="$sudo $PCP_BINADM_DIR/pmsignal"
101 # for local PMNS to avoid conflict with pmcd tests
103 NAMESPACE
="-n $here/src/root_irix"
110 $sudo chmod u
+w
$CONFIG
111 cp $CONFIG $CONFIGSAVE
112 [ -f $LOGCONTROL ] && $sudo mv $LOGCONTROL $SAVE_LOGCONTROL
120 $signal -s TERM
$pmcd
123 $sudo cp $CONFIGSAVE $CONFIG
124 $sudo chmod u-w
$CONFIG
125 [ -f $SAVE_LOGCONTROL ] && $sudo mv $SAVE_LOGCONTROL $LOGCONTROL
127 echo "Restart and ping pmcd ..."
130 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
133 pmprobe pmcd.control.debug
134 sleepers
=`ps $PCP_PS_ALL_FLAGS | grep '[d]umb_pmda' | $PCP_AWK_PROG '$3 == 1 { print $2 }'`
135 [ ! -z "$sleepers" ] && $sudo $signal -s KILL
$sleepers
137 $sudo rm -rf $tmp $tmp.
*
140 trap "_cleanup; exit \$status" 0 1 2 3 15
142 # real QA test starts here
144 $sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
145 $sudo $signal -a pmgadgets pmchart pmview
>/dev
/null
2>&1
147 $sudo $signal -a -s TERM pmie
>/dev
/null
2>&1
149 # Make our own version of pmcd.conf with dummy agents that will time out.
150 # Copy the pmcd PMDA from the original pmcd.conf so that we can check pmcd's
151 # timeouts by storing into pmcd.control.timeout
152 # NOTE: none of the domains should clash with the pmcd PMDA (domain 2) or the
153 # sample agent (domain 254). These agents will be appended to the file.
155 echo "fake_irix 1 pipe binary $here/src/dumb_pmda -d 1 fake_irix" >$NEWCONFIG
156 echo "fake_sampledso 30 pipe binary $here/src/dumb_pmda -d 30 fake_sampledso" >>$NEWCONFIG
157 echo "fake_cisco 5 pipe binary $here/src/dumb_pmda -d 5 fake_cisco" >>$NEWCONFIG
158 echo "fake_linux 60 pipe binary $here/src/dumb_pmda -d 60 fake_linux" >>$NEWCONFIG
159 grep pmda_pmcd
$CONFIGSAVE |
sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//' >>$NEWCONFIG
160 echo "[access]" >>$NEWCONFIG
161 echo "allow localhost : all;" >>$NEWCONFIG
162 echo "disallow * : all;" >>$NEWCONFIG
163 $sudo cp $NEWCONFIG $CONFIG
165 echo '$PCP_PMCDCONF_PATH contains:'
168 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
172 # Use a different port to avoid interference by remote monitors
174 port
=`_find_free_port 5432`
175 export PMCD_PORT
=$port
176 export PMCD_SOCKET
=$tmp/pmcd.socket
178 # Note: start pmcd with -f so that its PID stays the same (no daemon)
179 # Also figure out which user we will run pmcd and its pmdas as
182 sudoopts
="-u $username"
183 id pcp
>/dev
/null
2>&1 && sudoopts
="-u pcp"
187 export PATH=$here/src:$PATH
188 $PCP_PMCD_PROG -f -t 2 &
191 pmcd
=`$sudo $sudoopts sh $tmp.sh`
193 # complete V1 PMDA timeouts, then wait for pmcd
198 # If agent not restarted then both messages will be "no agent for domain..."
200 echo "Expect \"IPC protocol failure\" ..."
201 pminfo
$NAMESPACE -d hinv.ncpu
203 # Now remove the fake_sampledso agent and add the sample agent from the
204 # original config file and restart PMCD.
205 # The config file has changed and there is also a dead agent to restart.
207 sed <$NEWCONFIG >$tmp.tmp \
210 '"`grep pmdasample $CONFIGSAVE | sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//'`"'
212 -e '/fake_sampledso/d'
213 mv $tmp.tmp
$NEWCONFIG
214 $sudo cp $NEWCONFIG $CONFIG
216 echo '$PCP_PMCDCONF_PATH now contains:'
219 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
220 -e '/^sample/s; [^ ]*pmdasample; ...pmdasample;' \
227 echo "Expect \"Unknown or illegal metric identifier\" ..."
228 pminfo
$NAMESPACE -d sampledso.control
229 echo "Expect \"IPC protocol failure\" ..."
230 pminfo
$NAMESPACE -d hinv.ncpu
231 echo "Expect 9 values available ..."
232 pmprobe
$NAMESPACE -v sample.bin
234 # Next, get the PID of the sample agent, copy the original config file back,
235 # restart PMCD (the sample agent's config line will be unchanged) and check
236 # that the sample agent has the same PID.
237 # The bogus fake_sampledso agent should have been terminated because it is
238 # no longer in the config file.
239 # That isn't enough to terminate the sleep agent.
242 echo "Deleting, adding and keeping agents test"
243 sample
=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
244 $1 == "value" { print $2 }
247 ps
-edf |
grep dumb_pmda |
grep fake_cisco
>/dev
/null ||
echo "Error: phony fake_cisco agent died prematurely"
249 $sudo cp $CONFIGSAVE $CONFIG
254 ps
-edf |
grep dumb_pmda |
grep fake_cisco
>/dev
/null
&& echo "Error: phony fake_cisco agent still lives!"
256 # Generate a PDU into the domain where the fake_sampledso agent used to be (#30 is
257 # assumed to be the sampledso PMDA)
259 echo "Getting a desriptor from domain 30 (fake_sampledso agent had this domain)"
260 pminfo
$NAMESPACE -md sampledso.control
262 # check pmdasample has same pid (not restarted)
264 sample2
=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
265 $1 == "value" { print $2 }
267 if [ "X$sample" != "X$sample2" ]
269 echo "Sample agent needlessly restarted (pid changed from $sample to $sample2)"