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
|
#! /bin/sh
# PCP QA Test No. 022
# proc PMDA exerciser
#
# Copyright (c) 2013-2014 Red Hat.
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard filters
. ./common.product
. ./common.filter
. ./common.check
pminfo proc.nprocs >/dev/null 2>&1 || _notrun "proc PMDA not installed"
# see if unix domain sockets are available (permissions)
_get_libpcp_config
target="-h localhost"
$unix_domain_sockets && target="-h unix:"
echo "target=$target" >>$seq_full
rm -f $seq.out
test -f $seq.out.$PCP_PLATFORM || _notrun "No validated output for $PCP_PLATFORM"
ln $seq.out.$PCP_PLATFORM $seq.out
trap "rm -f $tmp.*; exit" 0 1 2 3 15
_filter_pmids()
{
sed \
-e 's/indom=[0-9][0-9]* \[/indom=INDOM [/g' \
-e 's/3\.[0-9][0-9]*\.[0-9][0-9]*/PMID/g' \
-e 's/\[3\.9]/[INDOM]/g' \
-e 's/60\.[0-9][0-9]*\.[0-9][0-9]*/PMID/g' \
-e 's/\[60\.9]/[INDOM]/g'
}
_proc_filter()
{
input=$1
# Set variables pid, ppid, cpid for process ids
eval `grep '^pid=' $input`
eval `grep '^cpid=' $input`
if [ -z "$pid" -o -z "$cpid" ]
then
cat $input
echo
[ -z "$pid" ] && echo "Arrgh, cannot find ^pid= line"
[ -z "$cpid" ] && echo "Arrgh, cannot find ^cpid= line"
return
fi
echo "+++ start proc_filter $1 +++" >>$seq_full
cat $input \
| tee -a $seq_full \
| sed \
-e '/proc.memory.*.txt/s/valfmt: [01]/valfmt: 0-or-1/' \
-e '/proc\.psinfo\.[us]time/s/valfmt: [01]/valfmt: 0-or-1/' \
-e '/unknown pid/d' \
-e '/Error: No data available/d' \
-e 's/^/ /' \
-e 's/$/ /' \
-e "s/\([^0-9]\)0*$pid\([^0-9]\)/\1PID\2/g" \
-e "s/\([^0-9]\)0*$ppid\([^0-9]\)/\1PPID\2/g" \
-e "s/\([^0-9]\)0*$cpid\([^0-9]\)/\1CPID\2/g" \
-e "s,$PCP_RUN_DIR/pmcd.socket,localhost," \
-e 's/^ //' \
-e 's/ $//' \
-e 's/fd=[0-9][0-9]*/fd=N/g' \
-e 's/inst \[.*\] value/inst [NNN] value/' \
-e 's/inst \[[0-9][0-9]* or ".*/inst [NNN]/' \
-e '/value /{
s/value [0-9][0-9]*/value INTEGER/
s/value ".*"/value STRING/
s/value \[.*\]/value BINARYDATA/
}' \
-e '/pmResult/s/ .* numpmid/ ... numpmid/' \
\
| $PCP_AWK_PROG '
/End Fetch Over Entire Instance Domain/ { all = 0; print; next; }
/Fetch Over Entire Instance Domain/ { all = 1 }
all == 1 && / [i]nst \[/ { skip = 1 }
all == 1 && /] [v]alue / { skip = 0; next }
all == 1 && skip == 1 { next }
all == 1 && $3 == "numval:" { $4 = "LOTS" }
{ print }' \
| _filter_pmids
echo "+++ end proc_filter $1 +++" >>$seq_full
}
# real QA test starts here
echo "=== pminfo -F output ===" >>$seq_full
# try fetching all proc metrics
# cull out the not supported msg component
pminfo $target -F proc \
| tee -a $seq_full \
| _inst_value_filter \
| sed -e '/value/d' \
-e '/not supported/d' \
-e '/No data available/d' \
-e '/instance identifier/d' \
-e '/^[ \t]*$/d' \
-e '/DISAPPEARED/d' \
-e '/^proc\.fd\.count$/d' \
> $tmp.info 2>&1
LC_COLLATE=POSIX sort -n $tmp.info
src/proc_test $target \
proc.psinfo.utime \
proc.psinfo.stime \
proc.memory.rss \
proc.memory.size \
> $tmp.out 2>&1
code=$?
echo >>$seq_full
echo "=== src/proc_test output ===" >>$seq_full
cat $tmp.out >>$seq_full
_proc_filter $tmp.out
if [ $code != 0 ]
then
echo $0: FAILED proc_test exit status = $code
echo $0: see $seq.full
exit 1
fi
#
# fetch all instances for one metric in each cluster,
# provided the metric is expected to have > 1 value
# if new clusters are added, add more here
#
echo ""
echo "All instances for selected metrics ..."
cat <<End-of-File | sed -e 's/[ ]*#.*//' -e '/^$/d' | while read cluster metric
#no values is possible# 0 proc.hog.cpu
8 proc.nprocs # singular value
8 proc.psinfo.sname # whole lot of values
9 proc.memory.textrss
#no values is possible# 10 proc.control.all.threads
#no values is possible# 11 proc.psinfo.cgroups
#no values is possible# 12 proc.psinfo.labels
13 proc.runq.sleeping
24 proc.id.euid_nm
31 proc.schedstat.cpu_time
32 proc.io.read_bytes
33 proc.smaps.anonymous
End-of-File
do
pminfo $target -F 2>$tmp.err $metric \
| sed \
-e '/Error: proc_instance: unknown pid:/d' \
-e '/Error: Metric not supported by this version of monitored application/d' \
-e '/^ *value /d' \
| $PCP_AWK_PROG '
/ [i]nst \[/ { skip = 1 }
/"] [v]alue/ { skip = 0; next }
skip == 1 { next }
{ print }'
sed -e '/unknown pid/d' $tmp.err > $tmp.err1
if [ -s $tmp.err1 ]
then
echo "Following is unexpected stderr output from pminfo"
echo "--------"
cat $tmp.err1
echo "--------"
fi
done
exit 0
|