summaryrefslogtreecommitdiff
path: root/qa/159
blob: 5e1f1ddb5b482ffe0f41b9e3f9611622c2678f54 (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
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
#! /bin/sh
# PCP QA Test No. 159
# check out cisco PMDA
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard filters
. ./common.product
. ./common.filter

if [ -z "$PCP_CISCO_ROUTER" ]
then
    echo "No cisco router set via PCP_CISCO_ROUTER" >$seq.notrun
    echo "$seq: [not run] `cat $seq.notrun`"
    exit 0
fi

# New cisco metrics in pcp2.2 
if [ $PCP_VER -ge 2300 ]
then
    rm -f $seq.out && ln $seq.out.3 $seq.out
elif [ $PCP_VER -ge 2200 ]
then
    rm -f $seq.out && ln $seq.out.2 $seq.out
else
    rm -f $seq.out && ln $seq.out.1 $seq.out
fi

status=1
signal=$PCP_BINADM_DIR/pmsignal
trap _cleanup 0 1 2 3 15

_cleanup()
{
    pmstore pmcd.control.tracenobuf 0 2>&1 >/dev/null
    _cleanup_agent
    rm -f $tmp.*
    exit $status
}

_cleanup_agent()
{
    cd $home/$iam

    [ -f $tmp_configfile ] && $sudo mv $tmp_configfile $configfile

    if grep $iam $tmp.pmcd.conf > /dev/null
    then
	$sudo ./Install < /dev/null > /dev/null 2>&1
    else
	$sudo ./Remove < /dev/null > /dev/null 2>&1
    fi

    [ -f $tmp.pmcd.conf ] && $sudo mv $tmp.pmcd.conf $PCP_PMCDCONF_PATH
    $sudo $signal -a -s HUP pmcd

    cd $here
}

_filter_ins()
{
    sed -e '/^Check/{
s/ 1 warnings, / /
s/ [0-9][0-9]* values/ SOME values/
}' \
	-e 's/.* \(hash table entries\)/  NNN \1/' \
	-e 's/.* \(non-leaf nodes\)/  NNN \1/' \
	-e 's/.* \(leaf nodes\)/  NNN \1/' \
	-e 's/.* \(bytes of symbol table\)/  NNN \1/' \
	-e '/make: Nothing to be done for/d' \
| $PCP_AWK_PROG '
	/currently unselected interfaces/  { interfaces=1; print; next }
        interfaces==1 { print "<interfaces>\n"; interfaces=0; next }
	{ print }'
}

# real QA test starts here
home=$PCP_PMDAS_DIR
iam=cisco
configdir=$PCP_VAR_DIR/config/$iam
configfile=$configdir/$iam.conf
tmp_configfile=/tmp/$iam.conf
if [ ! -d $home/$iam ]
then
    echo "Where is $home/$iam?"
    exit 1
fi
cd $home/$iam
unset ROOT MAKEFLAGS

if [ -f Makefile ]
then
    if $sudo make clobber 2>&1 >$tmp.out
    then
	:
    else
	cat $tmp.out
	echo "Arrgh, make clobber failed"
	exit 1
    fi
fi

# copy the pmcd config file to restore state later
cp $PCP_PMCDCONF_PATH $tmp.pmcd.conf

# copy the agent config file to restore state later
[ -f $configfile ] && $sudo mv $configfile $tmp_configfile

echo
echo "=== remove agent ==="
$PCP_BINADM_DIR/pmpost "start watching for qa/159"
pmstore pmcd.control.tracenobuf 1>/dev/null 2>&1
$sudo ./Remove \
| sed -e 's/not found in Name Space, this is OK/done/'

if pminfo -v cisco
then
    echo "... failed!"
    if [ -d $PCP_LOG_DIR/pmcd ]
    then
	cat $PCP_LOG_DIR/pmcd/pmcd.log
    else
	cat $PCP_LOG_DIR/pmcd.log
    fi
    echo
    tail $PCP_LOG_DIR/NOTICES
fi
pmstore pmcd.control.tracenobuf 0 1>/dev/null 2>&1
$PCP_BINADM_DIR/pmpost "end watching for qa/159"

cat <<End-of-File >$tmp.in
both
$PCP_CISCO_ROUTER

End-of-File
if [ $PCP_VER -gt 2200 ]
then
    echo >>$tmp.in
fi
cat <<End-of-File >>$tmp.in
s2/3
e1/0
quit
$PCP_CISCO_ROUTER

End-of-File
if [ $PCP_VER -gt 2200 ]
then
    echo >>$tmp.in
fi
cat <<End-of-File >>$tmp.in
s2/0
quit

End-of-File

echo
echo "=== install agent ==="
$sudo ./Install <$tmp.in >$tmp.out 2>&1
_filter_ins <$tmp.out
pminfo -v `pminfo cisco | grep -v bytes_out_bcast` || echo "... failed!"

echo
echo "=== re-install agent ==="
$sudo ./Install <$tmp.in >$tmp.out 2>&1
_filter_ins <$tmp.out
pminfo -v `pminfo cisco | grep -v bytes_out_bcast` || echo "... failed!"

status=0
exit