This file is indexed.

/var/lib/pcp/testsuite/951 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
278
279
280
#!/bin/sh
# PCP QA Test No. 951
# test pmie's instant (unary) operator
#
# Copyright (c) 2015 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

status=1	# failure is the default!
$sudo rm -rf $tmp.* $seq.full
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15

_filter()
{
    # Sun May 24 17:33:21 2015: ....
    #
    sed \
	-e 's/^.* [0-2][0-9]:[0-5][0-9]:[0-5][0-9] ....:/DATE:/' \
	-e '/Info: evaluator exiting/d' \
	-e '/^[ 	]*$/d' \
    # end
}

# need to reduce this pmie output
# expr_1 (Mon May 25 07:03:17 2015): 195905 62019
# to
# 07:03:17 195905 62019
#
_fix_pmie()
{
    sed -n <$1 \
	-e '/expr_/{
s/^[a-zA-Z_0-9]* (//
s/^[A-Za-z ]*//
s/^[0-3][0-9] //
s/[0-9][0-9][0-9][0-9])://
s/  *$//
s/  */ /g
p
}' \
    | LC_COLLATE=POSIX sort >$tmp.tmp
    mv $tmp.tmp $1
}

# need to redce this pmval output
# 07:03:17.295               196001                 62142
# to
# 07:03:17 196001 62142
#
_fix_pmval()
{
    sed -n <$1 \
	-e 's/No values available/?/' \
	-e '/^[0-2]/{
s/\.[0-9][0-9]*[0-9]//
s/  *$//
s/  */ /g
p
}' \
    | LC_COLLATE=POSIX sort >$tmp.tmp
    mv $tmp.tmp $1
}

_check_1()
{
    echo "=== check_1 input ===" >>$seq.full
    ( echo "--- tmp.1 ---" ; cat $tmp.1 ) >>$seq.full
    ( echo "--- tmp.2 ---" ; cat $tmp.2 ) >>$seq.full
    _fix_pmie $tmp.1
    _fix_pmval $tmp.2
    echo "=== check_1 pre-join ===" >>$seq.full
    ( echo "--- tmp.1 ---" ; cat $tmp.1 ) >>$seq.full
    ( echo "--- tmp.2 ---" ; cat $tmp.2 ) >>$seq.full
    join -j1 -a1 -a2 $tmp.1 $tmp.2 \
    | $PCP_AWK_PROG '
	{ nval = (NF-1)/2
	  for (i = 2; i <= nval+1; i++) {
	    if ($i == $(i+nval)) $0 = $0 " OK"
	    else $0 = $0 " BAD"
	  }
	  print
	}' \
    | _filter
}

# after stripping the ): we have lines like ...
# 07:03:17 195905 62019 ? ?
#          x[2]
# 07:03:18 196001 62142 96 123
#                       d
# expecting d == $2 - x[2] and similar for other disks
#
_check_2()
{
    echo "=== check_2 input ===" >>$seq.full
    ( echo "--- tmp.1 ---" ; cat $tmp.1 ) >>$seq.full
    ( echo "--- tmp.2 ---" ; cat $tmp.2 ) >>$seq.full
    _fix_pmie $tmp.1
    _fix_pmval $tmp.2
    echo "=== check_2 pre-join ===" >>$seq.full
    ( echo "--- tmp.1 ---" ; cat $tmp.1 ) >>$seq.full
    ( echo "--- tmp.2 ---" ; cat $tmp.2 ) >>$seq.full
    join -j1 -a1 -a2 $tmp.2 $tmp.1 \
    | sed -e 's/)://g' \
    | $PCP_AWK_PROG '
	{ nval = (NF-1)/2
	  for (i = 2; i <= nval+1; i++) {
	    if ($i == "?") {
		x[i] = ""
	    }
	    else {
		if (x[i] != "") {
		    if ($i - x[i] == $(i+nval)) $0 = $0 " OK"
		    else $0 = $0 " BAD"
		}
		x[i] = $i
	    }
	  }
	  print
	}'
}

# real QA test starts here

# note that this is a counter metric and values will be
# interpolated and then the value (not the rate) reported
#
echo "=== instant disk.dev.total(PM_SEM_COUNTER) ==="
echo "instant disk.dev.total;" \
| pmie -z -v -t 1sec -a archives/instant-base >$tmp.1 2>&1
# check
pmval -z -t1 -r -a archives/instant-base disk.dev.total >$tmp.2 2>&1
_check_1

# note that this is an instantaneous metric and values will
# be extrapolated
#
echo
echo "=== disk.dev.total(PM_SEM_INSTANT) ==="
echo "(expect slightly smaller values than the case above)"
echo "disk.dev.total;" \
| pmie -z -v -t 1sec -a archives/instant-1 >$tmp.1 2>&1
# check
pmval -z -t1 -a archives/instant-1 disk.dev.total >$tmp.2 2>&1
_check_1

# note that this is a counter metric and values will be
# interpolated and then the rate reported
#
echo
echo "=== (rate) disk.dev.total(PM_SEM_COUNTER) ==="
echo "disk.dev.total;" \
| pmie -z -v -t 1sec -a archives/instant-base >$tmp.1 2>&1
# check
pmval -z -t1 -a archives/instant-base disk.dev.total >$tmp.2 2>&1
_check_1

#
echo
echo "=== rate disk.dev.total(PM_SEM_INSTANT) ==="
echo "rate disk.dev.total;" \
| pmie -z -v -t 1sec -a archives/instant-1 >$tmp.1 2>&1
pmval -z -t1 -a archives/instant-1 disk.dev.total >$tmp.2 2>&1
_check_2

echo
echo "=== extra cases with PM_SEM_COUNTER archive ==="
cat <<End-of-File >$tmp.config
ruleset
some_inst disk.dev.total == disk.dev.read + disk.dev.write
    -> print "rate converted OK"
unknown
    -> print "rate converted UNKNOWN"
otherwise
    -> print "rate converted BAD: read+write != total" " [%i] %v"
;
ruleset
some_inst instant disk.dev.total == instant disk.dev.read + instant disk.dev.write
    -> print "instant OK"
unknown
    -> print "instant UNKNOWN"
otherwise
    -> print "instant BAD: read+write != total" " [%i] %v"
;
End-of-File
pmie -z -c $tmp.config -t 1sec -a archives/instant-base 2>&1 \
| _filter

echo
echo "=== extra cases with PM_SEM_INSTANT archive ==="
cat <<End-of-File >$tmp.config
ruleset
some_inst disk.dev.total == disk.dev.read + disk.dev.write
    -> print "raw OK"
unknown
    -> print "raw UNKNOWN"
otherwise
    -> print "raw BAD: read+write != total" " [%i] %v"
;
ruleset
some_inst rate disk.dev.total == rate disk.dev.read + rate disk.dev.write
    -> print "rate OK"
unknown
    -> print "rate UNKNOWN"
otherwise
    -> print "rate BAD: read+write != total" " [%i] %v"
;
End-of-File
pmie -z -c $tmp.config -t 1sec -a archives/instant-1 2>&1 \
| _filter

echo | tee -a $seq.full
echo "=== live pmcd cases ===" | tee -a $seq.full
cat <<End-of-File >$tmp.config
instant sum_inst disk.dev.total;
sum_inst instant disk.dev.total;
ruleset
    instant sum_inst disk.dev.total == sum_inst instant disk.dev.total
	-> print "OK: instant sum_inst == sum_inst instant"
    unknown
	-> print "UNKNOWN: instant sum_inst ..."
    otherwise
	-> print "BAD: instant sum_inst != sum_inst instant"
;

// repeating this expression revealed a horrible bug in pmie relating
// to the "rate" operator in changeSmpls() and nothing to do with
// "instant" but delayed the debugging for "instant" by days!
//
rate instant(pmcd.pdu_out.total);
rate instant(pmcd.pdu_out.total);

ruleset
    rate instant(pmcd.pdu_out.total) == pmcd.pdu_out.total
	-> print "OK: rate instant <x> == <x>"
    unknown
	-> print "UNKNOWN: rate instant ..."
    otherwise
	-> print "BAD: rate instant <x> != <x>"
;
End-of-File

pmie -v -c $tmp.config -t 0.5sec -T 2sec >$tmp.out 2>&1
grep expr $tmp.out >>$seq.full
grep -v expr $tmp.out | _filter

now=`pmprobe -v pmcd.pdu_in.text_req | cut -d ' ' -f 3`
limit=`expr $now + 4`

echo
echo "=== man page example ==="
cat <<End-of-File | pmie -t 0.25 -T 2 2>&1 | tee -a $seq.full | _filter | LC_COLLATE=POSIX sort | uniq
pmcd.pdu_in.text_req > 3;
instant pmcd.pdu_in.text_req < $limit;
pmcd.pdu_in.text_req > 3 && instant pmcd.pdu_in.text_req < $limit;
ruleset
    // rate should be 4 per sec
    pmcd.pdu_in.text_req > 3 && instant pmcd.pdu_in.text_req < $limit
	-> shell "echo TRUE"
    unknown
	-> shell "echo UNKNOWN"
    otherwise
	-> shell "echo FALSE"
;

// this bumps the count and hence the rate
hinv.ncpu > 0 -> shell "pminfo -t pmcd.pdu_in.text_req >/dev/null";
End-of-File

# success, all done
status=0

exit