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
|
#!/bin/sh
# PCP QA Test No. 941
# pmcd health check
#
# 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) 2017 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"
[ -f $seq.full ] && mv $seq.full $seq.full.save
fi
$check || echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
[ -f $seq_full.save ] && mv $seq_full.save $seq_full
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
# real QA test starts here
_get_pids_by_name pmcd >$tmp.pids
num_pmcds=`cat $tmp.pids | wc -l | sed -e 's/ //g'`
if $check
then
echo "--- running 941 --check @ `date` ---"
echo "_get_pids_by_name pmcd ..."
cat $tmp.pids
$PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp.ps.out
echo "$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep pmcd ..."
grep -E '[P]PID|/[p]mcd( |$)' <$tmp.ps.out
echo "num_pmcds=$num_pmcds (should be 1)"
fi
case "$num_pmcds"
in
0)
echo "Error: no pmcd running!"
status=1
exit
;;
1)
$check || echo "OK: one pmcd running"
;;
*)
echo "Error: $num_pmcds pmcd processes running"
$PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp.ps
for pid in `cat $tmp.pids`
do
$PCP_AWK_PROG <$tmp.ps '$2 == '$pid' { print }' >$tmp.out
if [ -s $tmp.out ]
then
grep PPID $tmp.ps
cat $tmp.out
else
echo "PID $pid has gone missing from ps(1) output?"
fi
for log in pmcd.log pmcd.log.prev
do
if [ -f $PCP_LOG_DIR/pmcd/$log ]
then
if grep "pmcd: PID = $pid," $PCP_LOG_DIR/pmcd/$log >/dev/null
then
echo "==> start matching $PCP_LOG_DIR/pmcd/$log file ==>"
cat $PCP_LOG_DIR/pmcd/$log
echo "<== end matching $PCP_LOG_DIR/pmcd/$log file <=="
fi
fi
done
done
status=1
exit
;;
esac
pid=`cat $tmp.pids`
if [ -f $PCP_LOG_DIR/pmcd/pmcd.log ]
then
if grep "pmcd: PID = $pid," $PCP_LOG_DIR/pmcd/pmcd.log >/dev/null
then
$check || echo "OK: pmcd.log is for running pmcd"
else
echo "Error: $PCP_LOG_DIR/pmcd/pmcd.log not for running pmcd (PID=$pid)"
echo "==> start $PCP_LOG_DIR/pmcd/pmcd.log file ==>"
cat $PCP_LOG_DIR/pmcd/pmcd.log
echo "<= end $PCP_LOG_DIR/pmcd/pmcd.log file <=="
$check && status=1
fi
else
echo "Error: $PCP_LOG_DIR/pmcd/pmcd.log missing!"
$check && status=1
fi
if [ -f $PCP_LOG_DIR/pmcd/pmcd.log.prev ]
then
if grep "pmcd: PID = $pid," $PCP_LOG_DIR/pmcd/pmcd.log.prev >/dev/null
then
echo "Error: $PCP_LOG_DIR/pmcd/pmcd.log.prev for running pmcd (PID=$pid)"
echo "==> start $PCP_LOG_DIR/pmcd/pmcd.log.prev file ==>"
cat $PCP_LOG_DIR/pmcd/pmcd.log.prev
echo "<= end $PCP_LOG_DIR/pmcd/pmcd.log.prev file <=="
$check && status=1
fi
fi
if [ -f $PCP_RUN_DIR/pmcd.pid ]
then
if [ "$pid" = "`cat $PCP_RUN_DIR/pmcd.pid`" ]
then
$check || echo "OK: run file has pmcd's pid"
else
echo "Error: $PCP_RUN_DIR/pmcd.pid -> PID `cat $PCP_RUN_DIR/pmcd.pid` not pmcd (PID=$pid)"
status=1
fi
else
echo "Error: $PCP_RUN_DIR/pmcd.pid missing"
status=1
fi
marker='PCP QA test'
# Did a QA test leave behind a modified pmcd.conf file?
#
if grep "$marker" $PCP_PMCDCONF_PATH >/dev/null
then
echo "Error: $PCP_PMCDCONF_PATH changed for QA, may not be correct"
grep "$marker" $PCP_PMCDCONF_PATH
status=1
else
$check || echo "OK: PMCDCONF_PATH not from a QA test"
fi
# Did a QA test leave behind a modified pmcd.options file?
#
if grep "$marker" $PCP_PMCDOPTIONS_PATH >/dev/null
then
echo "Error: $PCP_PMCDOPTIONS_PATH changed for QA, may not be correct"
grep "$marker" $PCP_PMCDOPTIONS_PATH
status=1
else
$check || echo "OK: PMCDOPTIONS_PATH not from a QA test"
fi
# success, all done
exit
|