/var/lib/pcp/testsuite/870 is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | #!/bin/sh
# PCP QA Test No. 870
# Various checks around the pmlogger control and run files in
# $PCP_TMP_DIR/pmlogger and $PCP_RUN_DIR
#
# With a single --check option, is silent except if there is a problem
# and runs just the integrity check. This could be used from check or
# check.callback
#
# Copyright (c) 2016 Ken McDonell. All Rights Reserved.
#
seq=`basename $0`
check=false
if [ $# -ge 1 -a "$1" = "--check" ]
then
check=true
# if 2nd arg present then use this as $seq ... we're being called from
# check.callback more than likely
#
[ $# -ge 2 -a "$2" != "" ] && seq="$2"
fi
$check || echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
status=1 # failure is the default!
$sudo rm -rf $tmp $tmp.*
$check || $sudo rm -f $seq.full
trap "cd $here; $sudo rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15
_check()
{
# start by iterating over all running pmlogger processes
#
if $check
then
echo "--- running 870 --check @ `date` ---" >>$here/$seq.full
status=0
fi
_get_pids_by_name pmlogger >$tmp.pmids
echo "_get_pids_by_name pmlogger ..." >>$here/$seq.full
cat $tmp.pmids >>$here/$seq.full
$PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp.ps.out
echo "$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep pmlogger ..." >>$here/$seq.full
grep pmlogger <$tmp.ps.out >>$here/$seq.full
if [ -s $tmp.pmids ]
then
# at least one is running
for pid in `cat $tmp.pmids`
do
$PCP_AWK_PROG <$tmp.ps.out >$tmp.ps.pid '
$2 == '"$pid"' { print }'
# control file(s) ...
#
if [ -f $PCP_TMP_DIR/pmlogger/$pid ]
then
# control file exists
if grep 'pmlogger .*-P ' <$tmp.ps.pid >/dev/null
then
# primary logger
if [ -L $PCP_TMP_DIR/pmlogger/primary ]
then
check_pid=`ls -l $PCP_TMP_DIR/pmlogger/primary | sed -e 's/.*\///'`
if [ "$check_pid" = "$pid" ]
then
# all is well
if $check
then
:
else
echo "control file check is OK"
fi
else
echo "Error: $PCP_TMP_DIR/pmlogger/primary linked to pid $check_pid instead of $pid"
head -1 $tmp.ps.out
$PCP_AWK_PROG <$tmp.ps.out '
$2 == '"$check_pid"' { print }'
cat $tmp.ps.pid
ls -l $PCP_TMP_DIR/pmlogger/*
$check && status=1
fi
else
echo "Error: $PCP_TMP_DIR/pmlogger/primary missing for ..."
head -1 $tmp.ps.out
cat $tmp.ps.pid
ls -l $PCP_TMP_DIR/pmlogger/*
$check && status=1
fi
else
# nothing more to check
:
fi
else
echo "Error: $PCP_TMP_DIR/pmlogger/$pid missing for ..."
head -1 $tmp.ps.out
cat $tmp.ps.pid
ls -l $PCP_TMP_DIR/pmlogger/*
$check && status=1
fi
# run file(s) ...
#
if [ -S $PCP_RUN_DIR/pmlogger.$pid.socket ]
then
# run file exists
if grep 'pmlogger .*-P ' <$tmp.ps.pid >/dev/null
then
# primary logger
if [ -L $PCP_RUN_DIR/pmlogger.primary.socket ]
then
check_pid=`ls -l $PCP_RUN_DIR/pmlogger.primary.socket | sed -e 's/.*\///' -e 's/pmlogger\.//' -e 's/\.socket//'`
if [ "$check_pid" = "$pid" ]
then
# all is well
if $check
then
:
else
echo "run file check is OK"
fi
else
echo "Error: $PCP_RUN_DIR/pmlogger.primary.socket linked to pid $check_pid instead of $pid"
head -1 $tmp.ps.out
$PCP_AWK_PROG <$tmp.ps.out '
$2 == '"$check_pid"' { print }'
cat $tmp.ps.pid
ls -l $PCP_RUN_DIR/pmlogger.*
$check && status=1
fi
else
echo "Error: $PCP_RUN_DIR/pmlogger.primary.socket missing for ..."
head -1 $tmp.ps.out
cat $tmp.ps.pid
ls -l $PCP_RUN_DIR/pmlogger.*
$check && status=1
fi
else
# nothing more to check
:
fi
else
echo "Error: $PCP_RUN_DIR/pmlogger.$pid.socket missing for ..."
head -1 $tmp.ps.out
cat $tmp.ps.pid
ls -l $PCP_RUN_DIR/pmlogger.*
$check && status=1
fi
done
else
echo "Warning: no pmloggers running"
$check && status=1
fi
# Check for dead control files with no pmlogger attached
#
for file in `cd $PCP_TMP_DIR/pmlogger; ls`
do
case "$file"
in
primary)
pid=`ls -l $PCP_TMP_DIR/pmlogger/primary | sed -e 's/.*\///'`
;;
*)
pid="$file"
;;
esac
$PCP_AWK_PROG <$tmp.ps.out >$tmp.ps.pid '
$2 == '"$pid"' { print }'
if [ -s $tmp.ps.pid ]
then
# OK
:
else
echo "Error: no matching pmlogger process for ..."
ls -l $PCP_TMP_DIR/pmlogger/$file
$check && status=1
fi
done
# Check for dead run files with no pmlogger attached
#
for file in `cd $PCP_RUN_DIR; ls pmlogger.*`
do
case "$file"
in
pmlogger.primary.socket)
pid=`ls -l $PCP_RUN_DIR/pmlogger.primary.socket | sed -e 's/.*\///' -e 's/pmlogger\.//' -e 's/\.socket//'`
;;
*)
pid=`echo $file | sed -e 's/pmlogger\.//' -e 's/\.socket//'`
;;
esac
$PCP_AWK_PROG <$tmp.ps.out >$tmp.ps.pid '
$2 == '"$pid"' { print }'
if [ -s $tmp.ps.pid ]
then
# OK
:
else
echo "Error: no matching pmlogger process for ..."
ls -l $PCP_RUN_DIR/$file
$check && status=1
fi
done
# And finally, at most 1 primary pmlogger
#
num_primary=`grep 'pmlogger .*-P ' <$tmp.ps.out | wc -l | sed -e 's/ //g'`
if [ "$num_primary" -gt 1 ]
then
echo "Error: more than one primary logger running ..."
head -1 $tmp.ps.out
grep 'pmlogger .*-P ' <$tmp.ps.out
$check && status=1
fi
}
# real QA test starts here
_check
$check && exit
echo
echo "start another primary pmlogger (expect failure) ..." | tee -a $here/$seq.full
_start_up_pmlogger -Dcontext -L -c /dev/null -l $tmp.log -P $tmp.arch
echo "pmlogger pid $pid" >>$here/$seq.full
for i in 1 2 3 4 5
do
present=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| $PCP_AWK_PROG '$2 == '"$pid"' { print "true"; exit } END { print "false" }'`
$present || break
sleep 1
done
if $present
then
echo "Arrggh ... pmlogger appears to be running ..."
$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| egrep "PID|$pid" \
| grep -v egrep
echo "kill off the primary pmlogger we just started ..."
$sudo kill -KILL $pid
for i in 1 2 3 4 5
do
present=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| $PCP_AWK_PROG '$2 == '"$pid"' { print "true"; exit } END { print "false" }'`
$present || break
sleep 1
done
if $present
then
echo "Arrggh ... failed to kill of pmlogger (pid $pid)"
$PCP_PS_PROG $PCP_PS_ALL_FLAGS \
| egrep "PID|$pid" \
| grep -v egrep
fi
fi
egrep 'ERROR:|info:' <$tmp.log \
| sed \
-e 's/pid [0-9][0-9]*/pid SOMEPID/g' \
-e "s@$PCP_TMP_DIR/@PCP_TMP_DIR/@g"
cat $tmp.log >>$here/$seq.full
_check
# success, all done
status=0
exit
|