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' \
91 CONFIG
=$PCP_PMCDCONF_PATH
92 NEWCONFIG
=$tmp/pmcd.conf
93 CONFIGSAVE
=$tmp/pmcd.conf.save
94 [ -z "$PCP_PMLOGGERCONTROL_PATH" ] && \
95 PCP_PMLOGGERCONTROL_PATH
="$PCP_SYSCONF_DIR/pmlogger/control"
96 LOGCONTROL
=$PCP_PMLOGGERCONTROL_PATH
97 SAVE_LOGCONTROL
=$tmp/control.save
98 signal
="$sudo $PCP_BINADM_DIR/pmsignal"
102 # for local PMNS to avoid conflict with pmcd tests
104 NAMESPACE
="-n $here/src/root_irix"
111 $sudo chmod u
+w
$CONFIG
112 cp $CONFIG $CONFIGSAVE
113 [ -f $LOGCONTROL ] && $sudo mv $LOGCONTROL $SAVE_LOGCONTROL
121 $signal -s TERM
$pmcd
124 $sudo cp $CONFIGSAVE $CONFIG
125 $sudo chmod u-w
$CONFIG
126 [ -f $SAVE_LOGCONTROL ] && $sudo mv $SAVE_LOGCONTROL $LOGCONTROL
128 echo "Restart and ping pmcd ..."
131 _service pcp restart | _filter_pcp_start
132 _restore_auto_restart pmcd
135 pmprobe pmcd.control.debug
136 sleepers
=`ps $PCP_PS_ALL_FLAGS | grep '[d]umb_pmda' | $PCP_AWK_PROG '$3 == 1 { print $2 }'`
137 [ ! -z "$sleepers" ] && $sudo $signal -s KILL
$sleepers
139 $sudo rm -rf $tmp $tmp.
*
142 trap "_cleanup; exit \$status" 0 1 2 3 15
144 _stop_auto_restart pmcd
146 # real QA test starts here
148 _service pcp stop | _filter_pcp_stop
149 $sudo $signal -a pmgadgets pmchart pmview
>/dev
/null
2>&1
151 $sudo $signal -a -s TERM pmie
>/dev
/null
2>&1
153 # Make our own version of pmcd.conf with dummy agents that will time out.
154 # Copy the pmcd PMDA from the original pmcd.conf so that we can check pmcd's
155 # timeouts by storing into pmcd.control.timeout
156 # NOTE: none of the domains should clash with the pmcd PMDA (domain 2) or the
157 # sample agent (domain 254). These agents will be appended to the file.
159 echo "fake_irix 1 pipe binary $here/src/dumb_pmda -d 1 fake_irix" >$NEWCONFIG
160 echo "fake_sampledso 30 pipe binary $here/src/dumb_pmda -d 30 fake_sampledso" >>$NEWCONFIG
161 echo "fake_cisco 5 pipe binary $here/src/dumb_pmda -d 5 fake_cisco" >>$NEWCONFIG
162 echo "fake_linux 60 pipe binary $here/src/dumb_pmda -d 60 fake_linux" >>$NEWCONFIG
163 grep pmda_pmcd
$CONFIGSAVE |
sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//' >>$NEWCONFIG
164 echo "[access]" >>$NEWCONFIG
165 echo "allow localhost : all;" >>$NEWCONFIG
166 echo "disallow * : all;" >>$NEWCONFIG
167 $sudo cp $NEWCONFIG $CONFIG
169 echo '$PCP_PMCDCONF_PATH contains:'
172 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
176 # Use a different port to avoid interference by remote monitors
178 port
=`_find_free_port 5432`
179 export PMCD_PORT
=$port
180 export PMCD_SOCKET
=$tmp/pmcd.socket
182 # Note: start pmcd with -f so that its PID stays the same (no daemon)
183 # Also figure out which user we will run pmcd and its pmdas as
186 sudoopts
="-u $username"
187 id pcp
>/dev
/null
2>&1 && sudoopts
="-u pcp"
191 export PATH=$here/src:$PATH
192 $PCP_PMCD_PROG -f -t 2 &
195 pmcd
=`$sudo $sudoopts sh $tmp.sh`
197 # complete V1 PMDA timeouts, then wait for pmcd
202 # If agent not restarted then both messages will be "no agent for domain..."
204 echo "Expect \"IPC protocol failure\" ..."
205 pminfo
$NAMESPACE -d hinv.ncpu
207 # Now remove the fake_sampledso agent and add the sample agent from the
208 # original config file and restart PMCD.
209 # The config file has changed and there is also a dead agent to restart.
211 sed <$NEWCONFIG >$tmp.tmp \
214 '"`grep pmdasample $CONFIGSAVE | sed -e 's/[ ][ ]*/ /g' -e 's/[ ]*$//'`"'
216 -e '/fake_sampledso/d'
217 mv $tmp.tmp
$NEWCONFIG
218 $sudo cp $NEWCONFIG $CONFIG
220 echo '$PCP_PMCDCONF_PATH now contains:'
223 -e '/^pmcd/s; [^ ]*pmda_pmcd.'$DSO_SUFFIX'; ...pmda_pmcd.$DSO_SUFFIX;' \
224 -e '/^sample/s; [^ ]*pmdasample; ...pmdasample;' \
231 echo "Expect \"Unknown or illegal metric identifier\" ..."
232 pminfo
$NAMESPACE -d sampledso.control
233 echo "Expect \"IPC protocol failure\" ..."
234 pminfo
$NAMESPACE -d hinv.ncpu
235 echo "Expect 9 values available ..."
236 pmprobe
$NAMESPACE -v sample.bin
238 # Next, get the PID of the sample agent, copy the original config file back,
239 # restart PMCD (the sample agent's config line will be unchanged) and check
240 # that the sample agent has the same PID.
241 # The bogus fake_sampledso agent should have been terminated because it is
242 # no longer in the config file.
243 # That isn't enough to terminate the sleep agent.
246 echo "Deleting, adding and keeping agents test"
247 sample
=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
248 $1 == "value" { print $2 }
251 ps
-edf |
grep dumb_pmda |
grep fake_cisco
>/dev
/null ||
echo "Error: phony fake_cisco agent died prematurely"
253 $sudo cp $CONFIGSAVE $CONFIG
258 ps
-edf |
grep dumb_pmda |
grep fake_cisco
>/dev
/null
&& echo "Error: phony fake_cisco agent still lives!"
260 # Generate a PDU into the domain where the fake_sampledso agent used to be (#30 is
261 # assumed to be the sampledso PMDA)
263 echo "Getting a desriptor from domain 30 (fake_sampledso agent had this domain)"
264 pminfo
$NAMESPACE -md sampledso.control
266 # check pmdasample has same pid (not restarted)
268 sample2
=`pminfo $NAMESPACE -f sample.daemon_pid | $PCP_AWK_PROG '
269 $1 == "value" { print $2 }
271 if [ "X$sample" != "X$sample2" ]
273 echo "Sample agent needlessly restarted (pid changed from $sample to $sample2)"