File: 279

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (204 lines) | stat: -rwxr-xr-x 5,148 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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#! /bin/sh
# PCP QA Test No. 279
# Check recovery actions when procedures in pmdaproc.sh fail to
# restart/start PMCD
#
# 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
. ./common.check

status=1	# failure is the default!
LOCALHOST=`hostname`
LOGGING_DIR="$PCP_ARCHIVE_DIR"
_needclean=true

# need PMDA executable someplace user $PCP_USER (pmcd) can read them
#
killer=$tmp.killparent
cp src/killparent $killer

_interrupt()
{
    status=1
}

_cleanup()
{
    if $_needclean
    then
	echo
	echo "Restoring real \$PCP_PMCDCONF_PATH ..."
	_restore_config $PCP_PMCDCONF_PATH
	$sudo rm -f $PCP_PMCDCONF_PATH.prev
	_restore_loggers
	_service pmcd restart 2>&1 | _filter_pcp_restart
	_wait_for_pmcd
	_restore_auto_restart pmcd
	_service pmlogger restart 2>&1 | _filter_pcp_restart
	_wait_for_pmlogger
	_needclean=false
    fi
    $sudo rm -f $tmp.*
    exit $status
}

_filter()
{
    $PCP_AWK_PROG '
BEGIN		{ skip = 0 }
/Save current/	{ print ""; skip = 0 }
/Sorry, failed/	{ print ""; skip = 0 }
skip == 0	{ print }
/Here is the PMCD logfile/	{ print "[logfile deleted]"; skip = 1; next }' \
    | sed \
	-e "s;$PCP_PMCDCONF_PATH;\$PCP_PMCDCONF_PATH;g" \
    | _filter_pcp_start \
    | _filter_pmcd_log \
    | _filter_pmcd \
    | sed \
	-e '/^Job for pmcd.service failed/d' \
	-e '/^See "systemctl  *status pmcd.service"/d' \
	-e '/^pmcd.service: /d' \
	-e '/^Job failed. See system journal/d' \
	-e '/^Terminated$/d' \
    # end
}

# This line may or may not appear ...
# $PCP_RC_DIR/pmcd: pmcd not running
#
_filter_pmcd()
{
    sed \
	-e '/^$PCP_RC_DIR\/pmcd: pmcd not running/d' \
    # end
}

_save_config $PCP_PMCDCONF_PATH
_disable_loggers || _exit 1
pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd

trap "_cleanup" 0
trap "_interrupt; _cleanup" 1 2 3 15

_stop_auto_restart pmcd

# real QA test starts here

# get to a known starting state, esp for pmcd.log
#
if [ $PCP_PLATFORM = linux ]
then
    cat <<End-of-File >$tmp.conf
# Installed by PCP QA test $seq on `date`
linux	60	dso	linux_init	$PCP_PMDAS_DIR/linux/pmda_linux.so
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
elif [ $PCP_PLATFORM = darwin ]
then
    cat <<End-of-File >$tmp.conf
# Installed by PCP QA test $seq on `date`
darwin	78	dso	darwin_init	$PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
End-of-File
elif [ $PCP_PLATFORM = solaris ]
then
    cat <<End-of-File >$tmp.conf
# Installed by PCP QA test $seq on `date`
solaris	75	dso	solaris_init	$PCP_PMDAS_DIR/solaris/pmda_solaris.so
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
elif [ $PCP_PLATFORM = freebsd ]
then
    cat <<End-of-File >$tmp.conf
# Installed by PCP QA test $seq on `date`
freebsd	85	dso	freebsd_init	$PCP_PMDAS_DIR/freebsd/pmda_freebsd.so
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
elif [ $PCP_PLATFORM = openbsd ]
then
    cat <<End-of-File >$tmp.conf
# Installed by PCP QA test $seq on `date`
openbsd	139	dso	openbsd_init	$PCP_PMDAS_DIR/openbsd/pmda_openbsd.so
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
else
    echo "Arrgh ... need pmcd.conf for PCP_PLATFORM $PCP_PLATFORM"
    exit 1
fi
echo "=== initial pmcd.conf ===" >>$seq_full
cat $tmp.conf >>$seq_full
echo "=== ===" >>$seq_full
$sudo cp $tmp.conf $PCP_PMCDCONF_PATH
if ! _service pmcd restart 2>&1; then _exit 1; fi \
| _filter_pcp_restart
_wait_for_pmcd || _exit 1
if ! _service pmlogger restart 2>&1; then _exit 1; fi \
| _filter_pcp_restart
_wait_for_pmlogger || _exit 1

cat <<End-of-File >$tmp.cmd
rm -f $PCP_PMCDCONF_PATH.prev
. $PCP_SHARE_DIR/lib/pmdaproc.sh
__can_wait=6
__pmda_add "bogus	111	pipe	binary 		$killer"
End-of-File

echo
echo "__pmda_add test: expect this to fail and revert to the status quo ..."
echo "__pmda_add test: expect this to fail and revert to the status quo ..." >>$seq_full
echo

$sudo sh $tmp.cmd 2>&1 \
| tee $tmp.out \
| _filter
cat $tmp.out >>$seq_full

echo "=== pmcd.conf after bogus install ===" >>$seq_full
cat $PCP_PMCDCONF_PATH >>$seq_full
echo "=== ===" >>$seq_full

echo "\$PCP_PMCDCONF_PATH should be put back the way it was ... diffs ..."
diff $PCP_PMCDCONF_PATH $tmp.conf

echo
cat <<End-of-File >$tmp.cmd
rm -f $PCP_PMCDCONF_PATH.prev
. $PCP_SHARE_DIR/lib/pmdaproc.sh
__can_wait=6
__pmda_cull fungus 222
End-of-File

echo "bogus 111     pipe    binary          $killer" >>$tmp.conf
echo "fungus 222     pipe    binary         $killer" >>$tmp.conf
echo "=== next pmcd.conf ===" >>$seq_full
cat $tmp.conf >>$seq_full
echo "=== ===" >>$seq_full
$sudo cp $tmp.conf $PCP_PMCDCONF_PATH

echo
echo "__pmda_cull test: expect this to fail and restoration to fail ..."
echo "__pmda_cull test: expect this to fail and restoration to fail ..." >>$seq_full
echo

$sudo sh $tmp.cmd 2>&1 \
| tee $tmp.out \
| _filter
cat $tmp.out >>$seq_full

echo "=== pmcd.conf after fungus remove ===" >>$seq_full
cat $PCP_PMCDCONF_PATH >>$seq_full
echo "=== ===" >>$seq_full

# success, all done
status=0

exit