summaryrefslogtreecommitdiff
path: root/qa/504
blob: 3aaa49aaf018cae64a596f77219d445d67fb9a20 (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
#! /bin/sh
# PCP QA Test No. 504
# exercises pmie_check functionality
# Version of No. 115 ... this one uses pmsocks
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

seq=`basename $0`

rm -f $seq.out
if [ $PCP_VER -lt 3810 ]
then
    ln $seq.out.1 $seq.out || exit 1
else
    ln $seq.out.2 $seq.out || exit 1
fi

echo "QA output created by $seq"

if [ "`pmsocks echo ok 2>&1`" != ok ]
then
    echo "pmsocks is not installed and/or not configured" >$seq.notrun
    echo "$seq: [not run] `cat $seq.notrun`"
    exit 0
fi

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

#  Requires common.product:
if [ "$PCP_VER" -lt 2200 ]
then
    echo "test aborted; known problem with pmsocks (#816862)" >$seq.notrun
    echo "$seq: [not run] `cat $seq.notrun`"
    exit 0
fi

signal=$PCP_BINADM_DIR/pmsignal
lhost=`hostname`
host=`_get_fqdn`
remote=`./getpmcdhosts -n 1 -L 2>/dev/null`
if [ -z "$PCP_PMIECONTROL_PATH" ]
then
    echo "Arrgh: Botch: PCP_PMIECONTROL_PATH not defined"
    exit 1
fi
needclean=false

_cleanup()
{
    if $needclean
    then
	$sudo cp $tmp.control.bak $PCP_PMIECONTROL_PATH
	$sudo chown pcp:pcp $PCP_PMIECONTROL_PATH
	$sudo chmod 664 $PCP_PMIECONTROL_PATH
	$sudo cp $tmp.pmcd.bak $PCP_PMCDCONF_PATH
	needclean=false
    fi
    $sudo rm -f $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e "s/$seq-$$/PID/g" \
	-e "s/$$/PID/g" \
	-e "s/$remote/REMOTEHOST/g" \
	-e "s/$host/LOCALHOST/g" \
	-e "s/$lhost/LOCALHOST/g" \
	-e "s/local:/LOCALHOST/g" \

}

_count_pmies()
{
    count=0
    if [ -d $PCP_TMP_DIR/pmie ] 
    then cd $PCP_TMP_DIR/pmie
    else return 0
    fi

    plist=`ls -1`
    cd $here

    for process in $plist
    do
	ps -p $process >/dev/null 2>&1
	if [ $? = 1 ]
	then
	    echo "urk, $PCP_TMP_DIR/pmie/$process has no running pmie instance"
	else
	    count=`expr $count + 1`
	fi
    done

    return $count
}

# create a basic pmcd config file
cat >$tmp.pmcd.conf << EOF
# from QA $seq
irix	1	dso	irix_init	libirixpmda.so
pmcd	2	dso	pmcd_init	pmda_pmcd.so
proc	3	dso	proc_init	pmda_proc.so
EOF

# create a pmie config file
cat >$tmp.conf << EOF
foo = sample.long.one;
doo = sample.long.ten;
EOF

# create pmie control file
cat >$tmp.control << EOF
\$version=1.0
LOCALHOSTNAME   y $tmp.log0 $tmp.conf
$remote         n $tmp.log1 -c $tmp.conf
$remote         y $tmp.log2 -c $tmp.conf
EOF

# real QA test starts here
cp $PCP_PMIECONTROL_PATH $tmp.control.bak
cp $PCP_PMCDCONF_PATH $tmp.pmcd.bak
needclean=true
$sudo cp $tmp.pmcd.conf $PCP_PMCDCONF_PATH 

$sudo $signal -a -s TERM pmie >/dev/null 2>&1
_change_config pmcd on
_change_config pmie off
$sudo rm -f $PCP_TMP_DIR/pmie/*

_count_pmies
echo "pmie count at start of QA testing: $?"
echo

SOCKS_SERVER=$PCPQA_SOCKS_SERVER
export SOCKS_SERVER

_change_config pmie on
$sudo cp $tmp.control $PCP_PMIECONTROL_PATH
$sudo chown pcp:pcp $PCP_PMIECONTROL_PATH
$sudo chmod 664 $PCP_PMIECONTROL_PATH

echo === check pmie_check and custom config ===
pmie_check -V -V -N -c $tmp.control 2>&1 | _filter
# don't bother counting pmie processes, as -N is used above!
#
echo

echo === check customised control file ===
$sudo $PCP_RC_DIR/pmie restart 2>&1 | _filter_pmie_start
sleep 30	# can take awhile, but in bg - TODO: really needs a "pmie_wait"
_count_pmies
echo "pmie count with custom config (expect 3): $?"
echo

$sudo $PCP_RC_DIR/pmie stop 2>&1 | _filter_pmie_start
_change_config pmie off

status=0
exit