This file is indexed.

/var/lib/pcp/testsuite/578 is in pcp-testsuite 3.9.10.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#! /bin/sh
# PCP QA Test No. 578
# Test for Bug #660497, change openfds metric to be the
# largest known file descriptor used by pmcd.
# This means the file descriptor can only ever increase.
# The following behaviour is expected:
#	the file descriptor will increase when a client or pmda connects
# 	the file descriptor will stay the same when a client or pmda disconnects
#
# 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

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

status=1	# failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
rm -f $seq.full

signal=$PCP_BINADM_DIR/pmsignal
simple_domain=253
if [ -x pmobjstyle ]
then
    style=`pmobjstyle`
else
    style=''
fi

_start_client()
{
    pmval -T 10sec kernel.all.load >$tmp.tmp 2>&1 &
    echo "=== Started client ===" | tee -a $here/$seq.full
    sleep 3
}

# Remove the PMDA and restore pmcd.conf
#
_cleanup()
{
    [ -f $PCP_PMDAS_DIR/simple/simple.conf.$seq ] && $sudo mv -f $PCP_PMDAS_DIR/simple/simple.conf.$seq $PCP_PMDAS_DIR/simple/simple.conf

    if [ -f $tmp.conf ]
    then
	echo "=== Resetting pmcd.conf back to original state ==="
	$sudo cp $tmp.conf $PCP_PMCDCONF_PATH
        $sudo cp $tmp.root $PCP_VAR_DIR/pmns/root
    fi
    if [ -f $tmp.conf ]
    then
    	echo "=== Restart PMCD ==="
	unset PMCD_PORT
	$sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
	_wait_for_pmcd
    fi
    
    if grep '^simple' $PCP_PMCDCONF_PATH >/dev/null
    then
	:
    else
	# simple was not installed, cull namespace
	#
	cd $PCP_PMDAS_DIR/simple
	$sudo ./Remove >/dev/null
    fi
    
    if [ -f $tmp.log ]
    then
	echo '=== pmcd log' >>$here/$seq.full
	cat $tmp.log >>$here/$seq.full
    fi

    rm -rf $tmp.*
}

trap "_cleanup; exit \$status" 0 1 2 3 15

_filter_ins()
{
    sed \
	-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/'
}

_filter_init()
{
    sed \
	-e "s/$$/PID/g"
}

_filter_openfds_value()
{
    $PCP_AWK_PROG '
BEGIN { fst_fds = "fst_fds"; sec_fds = "sec_fds"; thr_fds = "thr_fds"; step = 0 }
$1 == "value" && step == 0 { 
	fst_fds = $2; step = 1; next }
$1 == "value" && step == 1 { 
	sec_fds = $2; step = 2; next }
$1 == "value" && step == 2 { 
	thr_fds = $2; 
	if (sec_fds > fst_fds)
	    printf("=== Info: After install, openfds has increased as expected ===\n");
	else {
	    printf("=== Error: After install, openfds has unexpectedly decreased or stayed the same ===\n");
	    printf("\t previous value %d, current value %d\n", fst_fds, sec_fds);
	    }
	if (sec_fds == thr_fds)
	    printf("=== Info: After remove, openfds has stayed the same as expected ===\n");
	else {
	    printf("=== Error: After remove, openfds has unexpectedly changed ===\n") 
	    printf("\t previous value %d, current value %d\n", sec_fds, thr_fds);
	    }
	next;
	}
	{ next } '
}

# no random clients, thanks
#
port=`_get_port tcp 6060 6070`
if [ -z "$port" ]
then
    echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
    netstat -an
    exit
fi
PMCD_PORT=$port
export PMCD_PORT

# Build simple agent
#
echo "=== Building simple agent ===" | tee -a $here/$seq.full
unset ROOT TOOLROOT MAKEFLAGS
cd $PCP_PMDAS_DIR/simple

# get rid of warnings from simple if no config exists
[ -f simple.conf ] && $sudo mv simple.conf simple.conf.$seq
echo "sec,min,hour" >$tmp.simple.conf
$sudo cp $tmp.simple.conf simple.conf

# Install the simple namespace, I don't bother to remove it again
#
$sudo ./Install -N < /dev/null | _filter_ins 2>&1
echo "Namespace installed"

if $sudo make > $tmp.make 2>&1
then
    echo "PMDA built"
else
    echo "Unable to build the simple PMDA:"
    cat $tmp.make
    exit
fi

sed -e "/^@ SIMPLE/s/SIMPLE/$simple_domain/" < help \
| $sudo $PCP_BINADM_DIR/newhelp -v 2 -o help
echo "Help generated"
cd $here

# Refresh PMCD
#
_renew_pmcd()
{
    echo "=== Restarting PMCD with minimal PMDAs ===" | tee -a $here/$seq.full
    if [ -f $tmp.newconf ]
    then
	$sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
	$sudo $signal -a -s HUP pmcd
	sleep 4
	_wait_for_pmcd
    else
	echo caller - $1 - has not created $tmp.newconf !!!
    fi
}

# Install a standard pmda, but do not mess with the namespace
#
_agent_install()
{
    agent=$1
    domain=$2
    daemon=$3
    path=$PCP_PMDAS_DIR/$agent

    echo "=== Installing $agent ===" | tee -a $here/$seq.full
    cp $tmp.newconf $tmp.latest
    if $daemon
    then
	cat << end-of-file >> $tmp.latest
$agent	$domain	pipe	binary	$path/pmda$agent -d $domain
end-of-file
    else
    	cat << end-of-file >> $tmp.latest
$agent	$domain	dso	${agent}_init	$path/${style}pmda_$agent.$DSO_SUFFIX
end-of-file
    fi

    $sudo cp $tmp.latest $PCP_PMCDCONF_PATH

    $sudo $signal -a -s HUP pmcd
    sleep 4
    _wait_for_pmcd

    if _check_agent $agent true
    then
    	echo "$agent is alive and well"
    else
    	echo "Failed to install $agent"
	exit
    fi
}

# Remove a pmda
#
_agent_remove()
{
    agent=$1

    echo "=== Removing $agent ===" | tee -a $here/$seq.full
    _renew_pmcd _agent_remove

    if _check_agent $agent true
    then
    	echo "Failed to remove $agent"
	exit
    else
    	echo "$agent was removed"
    fi
}

# real QA test starts here

# Copy and replace pmcd.conf
#
cp $PCP_PMCDCONF_PATH $tmp.conf
cp $PCP_VAR_DIR/pmns/root $tmp.root

if [ $PCP_PLATFORM = linux ] 
then
    cat << end-of-file > $tmp.newconf
# pmcd.conf generated by QA $seq
pmcd    2       dso     pmcd_init       $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
linux   60      dso     linux_init      $PCP_PMDAS_DIR/linux/pmda_linux.so
end-of-file
elif [ $PCP_PLATFORM = irix ]
then
    cat << end-of-file > $tmp.newconf
# pmcd.conf generated by 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
end-of-file
elif [ $PCP_PLATFORM = darwin ]
then
    cat << end-of-file > $tmp.newconf
# pmcd.conf generated by QA $seq
pmcd    2       dso     pmcd_init       $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
darwin  78      dso     darwin_init     $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
end-of-file
elif [ $PCP_PLATFORM = solaris ]
then
    cat << end-of-file > $tmp.newconf
# pmcd.conf generated by QA $seq
pmcd	2	dso	pmcd_init	$PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
solaris	75	dso	solaris_init	$PCP_PMDAS_DIR/solaris/pmda_solaris.so
end-of-file
else
    echo "Arrgh ... need pmcd.conf output for $PCP_PLATFORM"
    exit 1
fi

#_renew_pmcd main

if [ -f $tmp.newconf ]
then
    $sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
fi

# Start with a fresh pmcd log
#
# need to do this indirectly because system sudo cleanses the environment
#
echo "export PMCD_PORT=$PMCD_PORT" >$tmp.start
echo "$PCP_RC_DIR/pcp restart" >>$tmp.start
$sudo sh $tmp.start | _filter_pcp_start | _filter_init 2>&1
_wait_for_pmcd

_test_pmda()
{
    pmda_type=$1

    # Test PMDA 
    #
    echo
    echo "=== Testing PMDA as a $pmda_type ===" | tee -a $here/$seq.full

    rm -f $tmp.pminfo

    pminfo -f pmcd.openfds >$tmp.pminfo
    fst_openfds=$openfds_value

    if [ "$pmda_type" != PIPE ]
    then
	_agent_install simple $simple_domain false
    else
	_agent_install simple $simple_domain true
    fi
    
    pminfo -f pmcd.openfds >>$tmp.pminfo
    
    _agent_remove simple
    pminfo -f pmcd.openfds >>$tmp.pminfo

    cat $tmp.pminfo | _filter_openfds_value
}

_test_client()
{
    # Test a client
    #
    echo "=== Testing a Client ===" | tee -a $here/$seq.full

    rm -f $tmp.pminfo

    pminfo -f pmcd.openfds >$tmp.pminfo

    _start_client
    pminfo -f pmcd.openfds >>$tmp.pminfo

    wait
    pminfo -f pmcd.openfds >>$tmp.pminfo

    echo "=== pmval output ===" >>$here/$seq.full
    cat $tmp.tmp >>$here/$seq.full
    echo "=== pminfo output ===" >>$here/$seq.full
    cat $tmp.pminfo >>$here/$seq.full
    
    cat $tmp.pminfo | _filter_openfds_value
}

_test_client
_test_pmda DSO
_test_pmda PIPE

status=0
# success, all done
exit