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
|
#!/bin/sh
# PCP QA Test No. 1206
# pmlogctl - mixed class and hostname tests - stop & start actions
#
# Copyright (c) 2020 Ken McDonell. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
if pmlogctl -c default status 2>/dev/null | grep ' default ' >/dev/null
then
_notrun "at least one pmlogger already defined for \"default\" class"
fi
_cleanup()
{
echo "_cleanup: ..." >>$seq_full
cd $here
$sudo pmlogctl -f -c default destroy localhost >>$seq_full 2>&1
$sudo pmlogctl -af -c $seq destroy >>$seq_full 2>&1
$sudo rm -rf $tmp $tmp.*
for dir in $seq-localhost $seq-LOCALHOSTNAME localhost $seq-`hostname`
do
[ -d "$PCP_ARCHIVE_DIR/$dir" ] && $sudo rm -rf "$PCP_ARCHIVE_DIR/$dir"
done
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
localhost=`hostname`
_filter()
{
tee -a $seq_full \
| sed \
-e '/^# created by pmlogctl/s/ on .*/ on DATE/' \
-e "s;$tmp\.;TMP.;g" \
-e "s;$PCP_BINADM_DIR/;PCP_BINADM_DIR/;g" \
-e "s;$PCP_ARCHIVE_DIR/;PCP_ARCHIVE_DIR/;g" \
-e "s;$PCP_TMP_DIR/;PCP_TMP_DIR/;g" \
-e "s;$PCP_TMPFILE_DIR/pmlogctl\.[^/]*;PCP_TMPFILE_DIR/pmlogctl.XXXXX;g" \
-e "s;$PCP_ETC_DIR/pcp;PCP_ETC_DIR/pcp;g" \
# end
}
# Build filter for any existing non-qa and non-primary pmlogger instances.
# The "pmcd Host" and "Class" fields from the pmlogctl status output
# should suffice to uniquely identify each.
#
pmlogctl status 2>&1 \
| $PCP_AWK_PROG >$tmp.awk '
NR == 1 { next }
NF >= 5 { if ($3 == "primary") next
print "$1 == \"" $1 "\" && $3 == \"" $3 "\" { next }"
}
END { print "{ print }" }'
# Note status command output order is non-deterministic, hence the sort
# at the end
#
_filter_status()
{
tee -a $seq_full \
| $PCP_AWK_PROG -f $tmp.awk \
| sed >$tmp.tmp \
-e "s;$PCP_ETC_DIR/pcp;PCP_ETC_DIR/pcp;g" \
-e "/^`hostname` .* primary /d" \
-e 's/[ ][ ]*/ /g' \
-e 's/2[0-9][0-9][0-9][01][0-9][0-3][0-9]\...\.[^ ]*/<archivename>/' \
-e "s/^$localhost /LOCALHOSTNAME /" \
-e "s/ $seq / <seq> /" \
-e 's/ [0-9][0-9]* / <pid> /' \
# end
head -1 $tmp.tmp
sed -e '1d' $tmp.tmp | LC_COLLATE=POSIX sort
}
cat <<End-of-File >$tmp.policy
[class]
$seq
[ident]
$seq-%h
[control]
%h n n PCP_ARCHIVE_DIR/%i -c $tmp.config
End-of-File
cat <<End-of-File >$tmp.config
log mandatory on default { pmcd.pmlogger }
End-of-File
# real QA test starts here
echo '== create running pmlogger instances' | tee -a $seq_full
$sudo pmlogctl -p $tmp.policy -c $seq create localhost | _filter
$sudo pmlogctl -p $tmp.policy -c $seq create LOCALHOSTNAME | _filter
$sudo pmlogctl create localhost | _filter
pmlogctl status | _filter_status
# exercise all the variants for "stop" and "start"
echo '== -a stop localhost' | tee -a $seq_full
$sudo pmlogctl -a stop localhost | _filter
pmlogctl status | _filter_status
echo '== -a start localhost' | tee -a $seq_full
$sudo pmlogctl -a start localhost | _filter
pmlogctl status | _filter_status
echo '== -a stop localhost `hostname`' | tee -a $seq_full
$sudo pmlogctl -a stop localhost `hostname` 2>$tmp.err | _filter_status
_filter <$tmp.err
pmlogctl status | _filter_status
echo '== -a start localhost `hostname`' | tee -a $seq_full
$sudo pmlogctl -a start localhost `hostname` 2>$tmp.err | _filter_status
_filter <$tmp.err
pmlogctl status | _filter_status
echo '== -a -c stop' | tee -a $seq_full
$sudo pmlogctl -a -c $seq stop | _filter_status
pmlogctl status | _filter_status
echo '== -a -c start' | tee -a $seq_full
$sudo pmlogctl -a -c $seq start | _filter_status
pmlogctl status | _filter_status
echo '== -a -c stop localhost' | tee -a $seq_full
$sudo pmlogctl -a -c $seq stop localhost | _filter_status
pmlogctl status | _filter_status
echo '== -a -c start localhost' | tee -a $seq_full
$sudo pmlogctl -a -c $seq start localhost | _filter_status
pmlogctl status | _filter_status
echo '== -a -c stop localhost `hostname`' | tee -a $seq_full
$sudo pmlogctl -a -c $seq stop localhost `hostname` | _filter_status
pmlogctl status | _filter_status
echo '== -a -c start localhost `hostname`' | tee -a $seq_full
$sudo pmlogctl -a -c $seq start localhost `hostname` | _filter_status
pmlogctl status | _filter_status
status=0
exit
|