File: 1033

package info (click to toggle)
pcp 7.0.5-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,916 kB
  • sloc: ansic: 1,478,844; sh: 177,285; xml: 160,462; cpp: 83,809; python: 24,349; perl: 18,303; yacc: 6,877; lex: 2,864; makefile: 2,694; awk: 165; fortran: 60; java: 52
file content (94 lines) | stat: -rwxr-xr-x 2,184 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 1033
# Exercise the named PMDA.
#
# Copyright (c) 2016 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

[ -d "$PCP_PMDAS_DIR/named" ] || _notrun "named PMDA not installed"
perl -e "use PCP::PMDA" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "perl PCP::PMDA module not installed"

status=1	# failure is the default!

_cleanup()
{
    $sudo rm -f $here/named.log*
    rm -f $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15

# PMNS order is non-deterministic
# Metric: named
#    non-leaf nameserver	<--- sort
#        leaf interval		<--- sort
# dbpmda> desc named.interval
#
_filter()
{
    $PCP_AWK_PROG '
BEGIN				{ state = 0 }
state == 1 && $1 == "dbpmda>"	{ state = 2 }
				{ outname = "'$tmp'." state; print >outname }
$1 == "Metric:"			{ state = 1 }'
    ( cat $tmp.0 ; LC_COLLATE=POSIX sort $tmp.1; cat $tmp.2 ) \
    | sed \
        -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;" \
        -e "s;$script;pmdanamed.pl;" \
	-e '/Direct mapping for metrics disabled/d' \
    | _filter_dumpresult
}

_filter_pmda_log()
{
    tee -a $seq_full \
    | sed \
        -e 's/^\(Log for pmda[^ ]* on\) .*/\1 HOST .../' \
        -e 's/^\(Log finished\) .*/\1 .../' \
        -e '/^$/d' \
    #end
}


# real QA test starts here
script=$PCP_PMDAS_DIR/named/pmdanamed.pl

# create a set of commands for dbpmda
cat >$tmp.cmds <<End-of-File
open pipe /usr/bin/env perl $script
children named
desc named.interval
fetch named.interval
End-of-File

export NAMED_STATS_USER=`id -u -n`
export NAMED_STATS_PROG=`which true`

# iterate over all of the pre-canned staticstics files
test="$here/named"
for file in $test/*.txt
do
    export NAMED_STATS_FILE="$file"
    PCP_PERL_PMNS=root /usr/bin/env perl $script > $tmp.root

    echo === Test case: `basename $file`
    $sudo rm -f named.log named.log.prev
    dbpmda -n $tmp.root -ie < $tmp.cmds 2>&1 | _filter
    # give PMDA a chance to notice dbpmda has closed the pipe
    # and write the "finished" message to the log
    #
    sleep 1
    _filter_pmda_log < named.log
done

# success, all done
status=0
exit