pmrep: further zbxsend python3 fixes
[pcp.git] / qa / 482
blob84214382fc0485f245c53de348887cf164aa973a
1 #! /bin/sh
2 # PCP QA Test No. 482
3 # exercise pmlogsummary "-B" option (display value distribution in bins)
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
15 status=1 # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18 # usage: _xtract metric
19 _xtract()
21 pmdumplog -D1 archives/binning $1 >$tmp.out 2>$tmp.err
22 cat $tmp.err $tmp.out \
23 | $PCP_AWK_PROG '
24 $1 == "pmResult" { state=1; time=$7; stamp=$6; next }
25 state == 1 && /\('"$1"'\)/ { state=2; next }
26 state == 2 { state=0; print time,stamp,$2; next }
27 NF==0 { state=0; next }' \
28 | LC_COLLATE=POSIX _POSIX2_VERSION=0 sort -u +1n -2
31 # usage: _filterbins nbins < pmlogsummary output (with args=-ymMB nbins)
32 _filterbins()
34 $PCP_AWK_PROG -v nbins=$1 '{
35 printf "(%d)\n", $5
36 for (i=0; i < nbins; i++)
37 printf " Bin%d = %d\n", i, $(7+(i*2))
41 # usage: _dobinning nbins min max < values
42 _dobinning()
44 size=`echo "scale=10; ( $3 - $2 ) / $1" | bc`
45 #echo BINSIZE=$size NBINS=$1
47 $PCP_AWK_PROG -v nbins=$1 -v size=$size -v min=$2 '
48 { for (i=0; i < nbins; i++) {
49 if ($1 >= (size*i) + min && $1 <= (size*(i+1))+min) {
50 #printf "%f is in bin %d\n", $1, i
51 bins[i]++
52 total++
54 #else
55 #printf "%f out of %f-%f\n", $1, (size*i)+min, (size*(i+1))+min
57 #printf "value is %f\n", $1
59 END { printf "(%d)\n", total
60 for (i=0; i < nbins; i++)
61 printf " Bin%d = %d\n", i, bins[i]
65 _noncounter_values()
67 $PCP_AWK_PROG '{
68 printf "%f\n", $3
69 if (count == 0 || $3 > max) max = $3
70 if (count == 0 || $3 < min) min = $3
71 count++
72 next
74 END { printf "COUNT=%d MAX=%f MIN=%f\n", count, max, min }'
77 _counter_values()
79 $PCP_AWK_PROG '{
80 if (count > 0) {
81 value = (($3 - prevval)/($2 - prevtime))/1000.0
82 printf "%f\n", value
83 if (count == 1 || value > max) max = value
84 if (count == 1 || value < min) min = value
86 count++
87 prevval = $3
88 prevtime = $2
89 next
91 END { printf "COUNT=%d MAX=%f MIN=%f\n", count-1, max, min }'
94 # real QA test starts here
95 echo
96 echo "=== testing instanteous metric value distribution ==="
97 nbins=3
98 _xtract sample.scale_step.time_up_nanosecs | _noncounter_values > $tmp.noncount
99 eval `fgrep COUNT $tmp.noncount`
100 #echo count=$COUNT maximum=$MAX minimum=$MIN
101 $PCP_ECHO_PROG $PCP_ECHO_N "QA calculates: ""$PCP_ECHO_C"
102 fgrep -v COUNT $tmp.noncount | _dobinning $nbins $MIN $MAX
104 $PCP_ECHO_PROG $PCP_ECHO_N "pmlogsummary calculates: ""$PCP_ECHO_C"
105 pmlogsummary -ymMB $nbins archives/binning sample.scale_step.time_up_nanosecs \
106 | _filterbins $nbins
108 echo
109 echo "=== testing counter metric value distribution ==="
110 nbins=4
111 _xtract sample.milliseconds | _counter_values > $tmp.count
112 eval `fgrep COUNT $tmp.count`
113 #echo count=$COUNT maximum=$MAX minimum=$MIN
114 $PCP_ECHO_PROG $PCP_ECHO_N "QA calculates: ""$PCP_ECHO_C"
115 fgrep -v COUNT $tmp.count | _dobinning $nbins $MIN $MAX
117 $PCP_ECHO_PROG $PCP_ECHO_N "pmlogsummary calculates: ""$PCP_ECHO_C"
118 pmlogsummary -ymMB $nbins archives/binning | fgrep sample.milliseconds \
119 | _filterbins $nbins
121 # misc checks
122 echo
123 echo "=== testing boundary conditions ==="
124 pmlogsummary -B 1 archives/binning >/dev/null 2>&1
125 [ $? -ne 0 ] && echo " urk - error test #1 failed!"
126 pmlogsummary -B 0 archives/binning >/dev/null 2>&1
127 [ $? -ne 0 ] && echo " urk - error test #2 failed!"
128 pmlogsummary -B -7 archives/binning >/dev/null 2>&1
129 [ $? -eq 0 ] && echo " urk - error test #3 failed!"
131 echo done.
132 echo
134 # success, all done
135 status=0
136 exit