summaryrefslogtreecommitdiff
path: root/qa/213
blob: f5ad597eaba864acbb93e4dea88c1db46f788951 (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
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
#! /bin/sh
# PCP QA Test No. 213
# exercise dbpmda with dynamic metrics
#
# Copyright (c) 2009 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

if echo help | dbpmda | grep -q children
then
    :
else
    echo "No dynamic metric support in dbpmda" >$seq.notrun
    echo "$seq: [not run] `cat $seq.notrun`"
    exit 0
fi

status=0	# success is the default!
username=`id -u -n`
$sudo rm -rf $tmp.* $seq.full
trap "_cleanup; exit \$status" 0 1 2 3 15
culldir=false

_cleanup()
{
    rm -f $tmp.*
    $sudo rm -f $files
    $culldir && $sudo rm -fr "$PCP_TMP_DIR/mmv"
}

# is a pre-existing mmv directory in place?  if so, write access needed
if [ -d "$PCP_TMP_DIR/mmv" ]
then
    [ -w "$PCP_TMP_DIR/mmv" ] || _notrun "Cannot write to $PCP_TMP_DIR/mmv"
    $sudo rm -rf $PCP_TMP_DIR/mmv/*
else
    culldir=true
    $sudo mkdir -p "$PCP_TMP_DIR/mmv"
    $sudo chown `whoami` "$PCP_TMP_DIR/mmv"    # local user - tmpdir writing
    $sudo chgrp $PCP_GROUP "$PCP_TMP_DIR/mmv"  # group pcp - pmdammv reading
fi

_filter()
{
    tee -a $seq.full \
    | sed \
	-e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;" \
	-e "s;$PCP_TMP_DIR;\$PCP_TMP_DIR;" \
	-e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
	-e 's/dbpmda([0-9][0-9]*)/dbpmda(PID)/' \
	-e "s/ -U $username//g" \
	-e "s/\.$DSO_SUFFIX/.DSO_SUFFIX/g" \
    | _filter_dumpresult
}

pipeargs=""
id pcp >/dev/null 2>&1 && pipeargs="-U $username"

# real QA test starts here
echo "=== DSO PMDA test ==="
cat <<End-of-File | dbpmda -ei 2>&1 | _filter
open dso $PCP_PMDAS_DIR/sample/pmda_sample.$DSO_SUFFIX sample_init 30
name 30.0.1001
name 30.0.1007
name 2.4.1
pmid sampledso.secret.foo.two
pmid sampledso.secret.foo.bar.grunt.snort.six
pmid sampledso.secret.foo.bar.max.redirect
children sampledso.secret.foo
traverse sampledso.secret.foo
children sampledso.secret.foo.bar
traverse sampledso.secret.foo.bar
End-of-File

echo
echo "=== Daemon PMDA test ==="
cat <<End-of-File | dbpmda -ei 2>&1 | _filter
open pipe $PCP_PMDAS_DIR/sample/pmdasample $pipeargs 29
name 29.0.1001
name 29.0.1007
name 2.4.1
pmid sample.secret.foo.two
pmid sample.secret.foo.bar.grunt.snort.six
pmid sample.secret.foo.bar.max.redirect
children sample.secret.foo
traverse sample.secret.foo
children sample.secret.foo.bar
traverse sample.secret.foo.bar
End-of-File

echo
echo "=== MMV PMDA test ==="
src/mmv_genstats
echo "installed mmv files ..."
find $PCP_TMP_DIR/mmv -type f | sed -e "s;$PCP_TMP_DIR;PCP_TMP_DIR;"
cat <<End-of-File >$tmp.pmns
root {
    mmv	70:*:*
}
End-of-File
cat <<End-of-File | dbpmda -ei -n $tmp.pmns 2>&1 | _filter
desc mmv.test.strings
fetch mmv.test.strings mmv.test.counter
text mmv.test.strings
store mmv.reload "1"
open pipe $PCP_PMDAS_DIR/mmv/pmdammv $pipeargs
desc mmv.test.strings
fetch mmv.test.strings mmv.test.counter
text mmv.test.strings
store mmv.reload "1"
desc mmv.no.such.metric
close
open dso $PCP_PMDAS_DIR/mmv/pmda_mmv.$DSO_SUFFIX mmv_init 70
desc mmv.test.strings
fetch mmv.test.strings mmv.test.counter
text mmv.test.strings
store mmv.reload "1"
End-of-File

# success, all done
exit