1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
#! /bin/sh
# PCP QA Test No. 067
# Test PMCD's ability to detect and cleanup agents it didn't create when they
# terminate
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard filters
. ./common.product
. ./common.filter
. ./common.check
which netstat >/dev/null 2>&1 || _notrun "netstat not installed"
rm -f $seq.out
_get_libpcp_config
if $ipv6 ; then
ln $seq.out.ipv6 $seq.out || exit 1
else
ln $seq.out.nonipv6 $seq.out || exit 1
fi
trap "rm -f $tmp.*; exit" 0 1 2 3 15
# real QA test starts here
signal=$PCP_BINADM_DIR/pmsignal
log=$PCP_PMCDLOG_PATH
LOCALHOST=`hostname`
LOGGING_DIR="$PCP_ARCHIVE_DIR"
_filter_log()
{
sleep 1
_filter_pmcd_log <$log \
| sed \
-e '/^$/d' \
-e 's/ *$//' \
-e 's/^$//' \
-e '/^->/d' \
-e '/^00[08]:/d' \
-e '/^sample/s/.*/sample agent.../' \
-e 's/fd=[0-9][0-9]*/fd=<n>/g' \
-e 's/^ ok [0-9]*/ ok <n>/g' \
-e '/^test/s/ *[0-9][0-9]* *[0-9][0-9]* ... bin/ <n> <n> <n> bin/' \
-e '/Resource busy/d' \
-e 's/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/' \
-e '/client connection from/,/^$/d' \
-e '/Cleanup/d' \
-e '/Info: spindle_stats_init/d' \
-e '/UNIX_DOMAIN_SOCKET/d' \
-e '/ContactAgents: agent/d' \
#end
}
_filter_pmda_log()
{
sed \
-e 's/^\(Log for pmda[^ ]* on\) .*/\1 HOST .../' \
-e 's/^\(Log finished\) .*/\1 .../'
}
_interrupt()
{
echo "Interrupted!"
_exit 1
}
_needclean=true
_cleanup()
{
if [ $_needclean ]
then
_restore_config $PCP_PMCDCONF_PATH
pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd
echo "Restarting pmcd"
_service pmcd restart 2>&1 | _filter_pcp_restart
_wait_for_pmcd
_restore_auto_restart pmcd
_service pmlogger restart 2>&1 | _filter_pcp_restart
_wait_for_pmlogger
_needclean=false
rm -f $tmp.*
fi
}
trap _interrupt 1 2 3 15 # refactor-ok
trap _cleanup 0
_stop_auto_restart pmcd
domain=246
if [ $PCP_PLATFORM = linux ]
then
cat >$tmp.config <<End-of-file
# Installed by PCP QA test $seq on `date`
linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
test $domain socket inet 2222
End-of-file
elif [ $PCP_PLATFORM = darwin ]
then
cat >$tmp.config <<End-of-file
# Installed by PCP QA test $seq on `date`
darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
test $domain socket inet 2222
End-of-file
elif [ $PCP_PLATFORM = solaris ]
then
cat >>$tmp.config <<End-of-File
# Installed by PCP QA test $seq on `date`
solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
test $domain socket inet 2222
End-of-File
elif [ $PCP_PLATFORM = freebsd ]
then
cat >>$tmp.config <<End-of-File
# Installed by PCP QA test $seq on `date`
freebsd 85 dso freebsd_init $PCP_PMDAS_DIR/freebsd/pmda_freebsd.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
test $domain socket inet 2222
End-of-File
elif [ $PCP_PLATFORM = openbsd ]
then
cat >>$tmp.config <<End-of-File
# Installed by PCP QA test $seq on `date`
openbsd 139 dso openbsd_init $PCP_PMDAS_DIR/openbsd/pmda_openbsd.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
test $domain socket inet 2222
End-of-File
else
echo "Error - need pmcd.conf setup for $PCP_PLATFORM"
exit 1
fi
# netstat -an formats
#
# Redhat 7.3 and 9
# tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN
#
# macOS 10.6
# tcp4 0 0 *.2222 *.* LISTEN
#
# openindiana
# *.2222 *.* 0 0 128000 0 LISTEN
#
$sudo $signal -a pmgadgets pmchart pmview pmie >/dev/null 2>&1
src/pmdashutdown -i 2222 -d $domain -l $tmp.pmdalog &
pid=$!
echo "pmdashutdown pid: $pid" >$seq_full
sleep 1
echo
echo "port 2222 should be listening"
netstat -an \
| tee -a $seq_full \
| grep '[.:]2222 ' \
| sed \
-e 's/127\.0\.0\.1/*/g' \
-e 's/0\.0\.0\.0/*/g' \
-e 's/:/./g' \
-e 's/.*\(\*.2222\).*\(LISTEN\).*/... \1 ... \2/'
echo
_save_config $PCP_PMCDCONF_PATH
$sudo cp $tmp.config $PCP_PMCDCONF_PATH
pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd
if ! _service pmlogger stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmlogger_end || _exit 1
if ! _service pmcd stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmcd_end || _exit 1
# Note: need to use $PCP_RC_DIR/* here, not _service pmcd so that
# systemd (if running) does not get to see the pmcd exit status
#
( $sudo $PCP_RC_DIR/pmcd start; $sudo $PCP_RC_DIR/pmlogger start ) 2>&1 | _filter_pcp_start
_wait_for_pmcd || _exit 1
_wait_for_pmlogger || _exit 1
# echo "config:"
# cat $config | sed -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;"
echo
# wait for pmdashutdown to finish
#
for t in 1 2 3 4 5 6
do
echo >>$seq_full
echo "wait for pmdashutdown to finish ... cycle $t" >>$seq_full
if ps $PCP_PS_ALL_FLAGS | tee -a $seq_full | cut -f1 | grep $pid >/dev/null 2>&1
then
sleep 2
else
break
fi
done
echo >>$seq_full
cat $tmp.pmdalog >>$seq_full
echo
echo "pmda log (should have terminated):"
_filter_pmda_log <$tmp.pmdalog
echo
$sudo $signal -a -s HUP pmcd
# wait for PMCD to finish writing log (or 5 seconds)
for t in 1 2 3 4 5
do
if grep -E '^Cleanup "test" agent' $log >/dev/null 2>&1
then
break
fi
sleep 1
done
_filter_log
|