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
|
#!/bin/sh
# PCP QA Test No. 623
# pmlogger_daily - options from environment
#
# Copyright (c) 2018 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 which xz >/dev/null 2>&1
then
PROG=xz
SUFF=xz
elif which bzip2 >/dev/null 2>&1
then
PROG=bzip2
SUFF=bz2
elif which gzip >/dev/null 2>&1
then
PROG=gzip
SUFF=gz
else
_notrun "cannot find a compression program!"
fi
NEEDREWRITE=$PCP_LOG_DIR/pmlogger/.NeedRewrite
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
[ -f $NEEDREWRITE.$seq ] && $sudo mv $NEEDREWRITE.$seq $NEEDREWRITE
}
DATE=`pmdate -3d '%Y%m%d'`
_setup_control()
{
echo '$version=1.1' >$tmp.control
for arg
do
echo "\$$arg" >>$tmp.control
done
echo "LOCALHOSTNAME n n $tmp $tmp.config" >>$tmp.control
cat $tmp.control >>$seq_full
}
_setup()
{
rm -f $tmp/* $tmp.log
pmlogcp archives/ok-mv-bigbin $tmp
for arch in $tmp/ok-mv-bigbin.*
do
touch -t ${DATE}0102 $arch
mv $arch `echo $arch | sed -e "s/ok-mv-bigbin/${DATE}.01.02/"`
done
}
_filter()
{
if [ $# -eq 0 ]
then
cmd=cat
elif [ -f "$1" ]
then
cmd="cat \"$1\""
else
return
fi
eval $cmd \
| tee -a $seq_full \
| sed \
-e '/pmlogger_daily.pid:.*[ []Permission denied/d' \
-e '/no pmlogger instance running for host/d' \
-e '/^pmlogger_daily:.*\.control:[0-9]]$/d' \
-e '/logging for host .* unchanged/d' \
-e '/^rm: cannot remove .*pmlogger_daily.stamp/d' \
-e '/^cp: cannot create regular file .*pmlogger_daily.stamp/d' \
-e '/^cp: .*\/pmlogger_daily.stamp: Permission denied/d' \
-e '/^.[r-][w-][x-].*pmlogger_daily.stamp/d' \
-e '/^rm: cannot remove .*pmlogger_daily.pid/d' \
-e '/^_save_prev_filename: unable to remove/d' \
-e '/^Warning: cannot save previous date-and-timestamp/d' \
-e '/^Warning: cannot install new date-and-timestamp/d' \
-e '/^Start: /d' \
-e '/^End[: ]/d' \
# end
}
_showfiles()
{
ls $tmp/* \
| sed \
-e "s@$tmp@TMP@" \
-e "s/\.$SUFF$/.compressed/" \
-e "s/$DATE/DATE/" \
# end
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
[ -f $NEEDREWRITE ] && $sudo mv $NEEDREWRITE $NEEDREWRITE.$seq
mkdir $tmp
echo "log mandatory on default { pmcd }" >$tmp.config
# real QA test starts here
echo "simple cmd args" | tee -a $seq_full
_setup_control
_filter $tmp.log
_setup
pmlogger_daily -P -D -f -X $PROG -x 1 -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_showfiles
echo | tee -a $seq_full
echo "simple env vars" | tee -a $seq_full
_setup
PCP_COMPRESS=$PROG PCP_COMPRESSAFTER=1 pmlogger_daily -P -D -f -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_showfiles
echo | tee -a $seq_full
echo "some error cases" | tee -a $seq_full
_setup
pmlogger_daily -P -D -f -x bozo -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
PCP_COMPRESSAFTER=bozo pmlogger_daily -P -D -f -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
pmlogger_daily -P -D -f -x 1 -X no-such-compression-tool -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
PCP_COMPRESS=no-such-compression-tool pmlogger_daily -P -D -f -x 1 -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_setup_control PCP_COMPRESSAFTER=bozo
pmlogger_daily -P -D -f -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
echo | tee -a $seq_full
echo "some warning cases" | tee -a $seq_full
_setup_control
_setup
PCP_COMPRESS=$PROG PCP_COMPRESSAFTER=1 PCP_COMPRESSREGEX='\.index$' pmlogger_daily -P -D -f -X no-such-compression-tool -x 7 -Y xyz -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_showfiles
_setup_control "PCP_COMPRESS='$PROG'" PCP_COMPRESSAFTER=1 "PCP_COMPRESSREGEX='\.(index|meta)$'"
_setup
PCP_COMPRESS=foo PCP_COMPRESSAFTER=42 PCP_COMPRESSREGEX='\.bar$' pmlogger_daily -P -D -f -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_showfiles
# success, all done
status=0
exit
|