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 227 228 229 230 231 232 233 234
|
#!/bin/sh
# PCP QA Test No. 326
# Check PMCD state change notification, aka PMCD reset
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
# Copyright (c) 2016 Red Hat, Inc.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard filters
. ./common.product
. ./common.filter
. ./common.check
if [ -f /etc/redhat-release ]
then
# Don't even bother on CentOS release 6.10 (Final) ... we've tried
# repeatedly to make this test work on this platform and it is not worth
# investing any more effort on.
#
if grep -E -q '^CentOS .* 6\.[0-9]|^Red Hat .* 6\.[0-9]' </etc/redhat-release
then
_notrun "don't bother on CentOS/RHEL 6"
fi
fi
signal=$PCP_BINADM_DIR/pmsignal
status=1
done_clean=false
LOCALHOST=`hostname`
iam=`id -un`
_cleanup()
{
if $done_clean
then
:
else
[ -n "$pmcd_pid" ] && $signal -s TERM $pmcd_pid
_restore_config $PCP_SYSCONF_DIR/labels
rm -f $tmp.*
done_clean=true
fi
exit $status
}
trap "_cleanup" 0 1 2 3 15
timezone=`pmprobe -v pmcd.timezone | $PCP_AWK_PROG '{print $3}'`
_filter_pmval_live()
{
# filter hostname, as we now fetch pmcd.hostname, sneakily
# also, if the pmda goes away between the pmFetch() and the pmGetDesc()
# then the -Dfetch diag has to report, for example
# value 2 2.8025969e-45 0x2
# instead of
# value 2
# so fix this as well
#
sed \
-e "/ value \"$REALHOST\"/d" \
-e "/ value \"$LOCALHOST\"/d" \
-e '/ [0-9]\..*e.*0x/s/ [0-9]\..*//' \
# end
}
_filter_pmval_arch()
{
# strip preamble, mask timestamp, deal with arithmetic imprecision
# and map this
# 07:59:58.062 !
# to this
# 07:59:58.062 No values available
#
sed \
-e '1,/^interval:/d' \
-e 's/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9]*[0-9]/TIMESTAMP/g' \
-e 's/ !/No values available/' \
| $PCP_AWK_PROG '
/No values available/ { print; next }
0 <= $2 && $2 < 1.1 { $2 = "non-negative number, less than 1.1" }
{ print }' \
| uniq
}
trap "_cleanup" 0 1 2 3 15
# real QA test starts here
_save_config $PCP_SYSCONF_DIR/labels
$sudo rm -rf $PCP_SYSCONF_DIR/labels/*
PMDA_PMCD_PATH=$PCP_PMDAS_DIR/pmcd/pmda_pmcd.$DSO_SUFFIX
cat <<End-of-File >$tmp.pmcd.config
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29 -U $iam -l $tmp.pmda.log
End-of-File
PMCD_PORT=`_find_free_port`
echo "PMCD_PORT=$PMCD_PORT" >>$seq_full
export PMCD_PORT
$PCP_BINADM_DIR/pmcd -f -c $tmp.pmcd.config -l $tmp.pmcd.log -U $iam -s $tmp.socket &
pmcd_pid=$!
echo "pmcd_pid=$pmcd_pid" >>$seq_full
_wait_for_pmcd || _exit 1
cat <<End-of-File >$tmp.config
log mandatory on default { pmcd.numagents sample.milliseconds }
End-of-File
# run pmlogger and pmval for about 30 seconds
pmlogger -h localhost -s 90 -t 0.33 -l $tmp.log -c $tmp.config $tmp &
pmlogger_pid=$!
pmval -h localhost -s 90 -t 0.33 -Z "$timezone" -D fetch pmcd.numagents >$tmp.pmval 2>&1 &
pmval_pid=$!
sleep 3
# need PPID in the 3rd field of the ps(1) output
#
pmda_pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| grep '/[p]mdasample' \
| $PCP_AWK_PROG '$3 == "'$pmcd_pid'" { print $2 }'`
if [ -z "$pmda_pid" ]
then
echo "Arrgh ... lost pmdasample process?"
echo "See $seq.full for details"
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '([P]PID)|(/[p]mcd)|(/[p]mda)' >>$seq_full
[ -n "$pmlogger_pid" ] && $signal -s TERM $pmlogger_pid
[ -n "$pmval_pid" ] && $signal -s TERM $pmval_pid
cat $tmp.pmcd.log >>$seq_full
cat $tmp.pmda.log >>$seq_full
exit
fi
echo "=== kill sample PMDA process ==="
$signal -s TERM $pmda_pid
sleep 3 # enough time for pmcd to restart it - once only
pmda_pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| grep '/[p]mdasample' \
| $PCP_AWK_PROG '$3 == "'$pmcd_pid'" { print $2 }'`
if [ -z "$pmda_pid" ]
then
echo "Arrgh ... lost pmdasample process?"
echo "See $seq.full for details"
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]m[cd]( |$)' >>$seq_full
[ -n "$pmlogger_pid" ] && $signal -s TERM $pmlogger_pid
[ -n "$pmval_pid" ] && $signal -s TERM $pmval_pid
cat $tmp.pmcd.log >>$seq_full
cat $tmp.pmda.log >>$seq_full
exit
fi
$signal -s TERM $pmda_pid
sleep 3 # and again
echo "=== SIGHUP PMCD ==="
$signal -s HUP $pmcd_pid
sleep 3
echo "=== drop sample PMDA, like Remove ==="
cat <<End-of-File >$tmp.pmcd.config
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
End-of-File
$signal -s HUP $pmcd_pid
sleep 3
echo "=== add sample PMDA, like Install ==="
cat <<End-of-File >$tmp.pmcd.config
# Installed by PCP QA test $seq on `date`
pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29 -U $iam -l $tmp.pmda.log
End-of-File
$signal -s HUP $pmcd_pid
sleep 3
sleep 3
$signal -s TERM $pmcd_pid
pmcd_pid=''
wait
echo >>$seq_full
echo "pmcd log ..." >>$seq_full
cat $tmp.pmcd.log >>$seq_full
echo
echo "Trace of observed state changes and PMDA count ..."
grep -E '(PMCD state)|( value )' $tmp.pmval \
| _filter_pmval_live \
| uniq
echo >>$seq_full
echo "pmlogger log ..." >>$seq_full
cat $tmp.log >>$seq_full
echo
echo "archive contents ..."
pmdumplog $tmp >$tmp.out 2>&1
grep -E '(<mark>)|(pmcd.numagents)' $tmp.out \
| _filter_pmdumplog \
| uniq
echo >>$seq_full
pmdumplog -m $tmp sample.milliseconds >>$tmp.dump 2>&1
nr=`grep '^[012]' <$tmp.dump | wc -l | sed -e 's/ */ /g'`
echo "archive dump ($nr records)" >>$seq_full
cat $tmp.dump >>$seq_full
# note clip after 6 filtered lines to avoid extra values that sometimes
# appear due to non-determinism in pmlogger fetch samples
#
echo
echo "sanity check with pmval | filter ..."
pmval -t 1 -a $tmp sample.milliseconds 2>&1 \
| tee -a $seq_full \
| _filter_pmval_arch \
| sed -e 6q
echo >>$seq_full
echo "unfiltered pmval live output" >>$seq_full
cat $tmp.pmval >>$seq_full
echo >>$seq_full
echo "unfiltered pmval archive output" >>$seq_full
pmval -t 1 -a $tmp sample.milliseconds >>$seq_full 2>&1
status=0
exit
|