summaryrefslogtreecommitdiff
path: root/qa/345
blob: da07d3f286fc04adca1fcae32538350bf8ed8dac (plain)
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
#!/bin/sh
# PCP QA Test No. 345
#
# PM_CONTEXT_LOCAL and PMNS operations involving derived and dynamic
# metrics
#
# Copyright (c) 2010 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

grep 'pmRegisterDerived' $PCP_DIR/usr/include/pcp/pmapi.h >/dev/null ||
    _notrun "No derived metric support"
grep __pmLocalPMDA $PCP_DIR/usr/include/pcp/impl.h >/dev/null ||
    _notrun "No libpcp support for __pmLocalPMDA"

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

cat <<End-of-File >$tmp.derive
sampledso.secret.derived.eek.eight = 2 * sampledso.secret.foo.bar.four
End-of-File

# with -f need to remove "inst" lines for the metric
# sampledso.secret.foo.bar.max.redirect as we will never find these
# aliased pmcd metrics with -L
# also strip blank lines to reduce "diff noise" later
#
_filter()
{
    $PCP_AWK_PROG '
$1 == "sampledso.secret.foo.bar.max.redirect"	{ print; skip = 1; next }
NF == 0						{ skip = 0; next }
skip == 1 && $1 == "inst"			{ next }
						{ print }'
}

# real QA test starts here
for metric_args in \
    "sampledso.secret.foo.bar.grunt.five sampledso.secret.derived.eek.eight sampledso.secret.foo.bar.grunt" \
    sampledso.secret.foo \
    sampledso.secret \
    sampledso
do
    for margs in '' -m -f
    do
	# -f for all of sampledso will never match ...
	[ "$metric_args" = sampledso -a -n "$margs" ] && continue
	for hargs in '' '-h localhost' '-L'
	do
	    args="$hargs $margs"
	    if [ -z "$hargs" ]
	    then
		echo | tee -a $seq.full
		echo "=== $args $metric_args ===" | tee -a $seq.full
		pminfo -c $tmp.derive $args $metric_args >$tmp.raw
		cat $tmp.raw >>$seq.full
		_filter <$tmp.raw \
		| LC_COLLATE=POSIX sort >$tmp.base
	    else
		$sudo pminfo -c $tmp.derive $args $metric_args >$tmp.raw
		echo "=== $args $metric_args" >>$seq.full
		cat $tmp.raw >>$seq.full
		_filter <$tmp.raw \
		| LC_COLLATE=POSIX sort >$tmp.tmp
		echo "--- $args diffs against baseline ---" | tee -a $seq.full
		diff -u $tmp.base $tmp.tmp \
		| sed -e "/---/s/.*/- baseline output/" \
		      -e "/+++/s/.*/+ $args output/" \
		| tee -a $seq.full
	    fi
	done
    done
done

# success, all done
exit