This file is indexed.

/var/lib/pcp/testsuite/1321 is in pcp-testsuite 4.0.1-1.

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
#!/bin/sh
# PCP QA Test No. 1321
# Test pmlogger dynamic PMNS support

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

# get standard environment, filters and checks
. ./common.prometheus

_pmdaprometheus_check || _notrun "prometheus pmda and/or load generator not installed"
_have_python266 && _notrun "python load generator does not currently work with python 2.6.6"

status=1	# failure is the default!
$sudo rm -rf $tmp $tmp.* $seq.full

_cleanup()
{
    $sudo $PCP_BINADM_DIR/pmsignal -s TERM $pmlogger_pid >/dev/null 2>&1
    echo "=== prometheus PMDA log ===" >>$here/$seq.full
    if [ -f $PCP_LOG_DIR/pmcd/prometheus.log ]
    then
	cat $PCP_LOG_DIR/pmcd/prometheus.log >>$here/$seq.full
    else
	echo "Error: PMDA log file is missing" >>$here/$seq.full
    fi
    rm -rf $tmp.*
}

_createURL()
{
    SRC=$1
    NMET=$2

    [ ! -d $tmp.datadir ] && mkdir -p $tmp.datadir

    _txt=$tmp.datadir/source$SRC.txt
    for j in $(seq 1 $NMET); do
	echo "# HELP metric$j local test metric" >>$_txt
	echo "# Type metric$j gauge" >>$_txt
	echo "metric$j {somelabel=\"somevalue\"} 0.0" >>$_txt
    done

    _url="$CONFIG_DIR/source$SRC.url"
    echo "file://$tmp.datadir/source$SRC.txt" >$_url
    echo;echo == Created URL file $_url
    # echo;echo == curl URL returns
    # curl -G -s `cat $_url` || exit 1
}

trap "_cleanup; _pmdaprometheus_restore_config >>$here/$seq.full; exit \$status" 0 1 2 3 15

_pmdaprometheus_save_config
_pmdaprometheus_install
_pmdaprometheus_wait_for_metric prometheus.control.calls
pminfo prometheus >/dev/null && echo ... pmda install succeeded

# start up pmlogger
echo 'log mandatory on default { prometheus }' >$tmp.pmlogger.config

echo;echo === pmlogger config ===
cat $tmp.pmlogger.config

rm -f $tmp.dynamic.*
pmlogger -t 1s -l $tmp.pmlogger.log -c $tmp.pmlogger.config $tmp.dynamic &
pmlogger_pid=$!

for n in `seq 1 4`; do
	# while pmlogger is fetching every 1s, we create a new URL every 2s.
	sleep 2
	_createURL $n $n
	echo;echo === prometheus live PMNS is now ===
	pminfo prometheus | LC_COLLATE=POSIX sort
done

# When new dynamic metrics are detected, the _next_ fetch will fetch them.
# So wait for a bit so pmlogger has a chance to fetch the new metrics.
sleep 2

# now kill pmlogger and check the new metrics appeared dynamically
$sudo $PCP_BINADM_DIR/pmsignal -s TERM $pmlogger_pid >/dev/null 2>&1

echo;echo === resulting archive contains the following prometheus metrics ===
pminfo -a $tmp.dynamic prometheus | LC_COLLATE=POSIX sort
# rm -rf /tmp/saved; mkdir -p /tmp/saved; cp $tmp.dynamic.* $PCP_LOG_DIR/pmcd/prometheus.log $tmp.pmlogger.log /tmp/saved

echo === prometheus.log === >> $here/$seq.full
cat $PCP_LOG_DIR/pmcd/prometheus.log >> $here/$seq.full

echo === pmlogger.log === >> $here/$seq.full
cat $tmp.pmlogger.log >> $here/$seq.full

_pmdaprometheus_remove

# success, all done
status=0
exit