This file is indexed.

/var/lib/pcp/testsuite/1090 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
 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
#!/bin/sh
# PCP QA Test No. 1090
# Reproduce https://github.com/performancecopilot/pcp/issues/14
#
# Copyright (c) 2015 Ken McDonell.  All Rights Reserved.
#

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

# get webapi glue (includes standard environment, filters and checks)
. ./common.webapi

which curl >/dev/null 2>&1 || _notrun "No curl binary installed"
[ -f ${PCP_BINADM_DIR}/pmwebd ] || _notrun "pmwebd package not installed"

_cleanup()
{
    cd $here
    _restore_auto_restart pmwebd
    _service pmwebd restart >/dev/null 2>&1
    rm -rf $tmp.*
}

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

_dump_curl()
{
    echo "$1 curl ..." >>$here/$seq.full
    echo "<stdout>" >>$here/$seq.full
    ( cat $tmp.out; echo ) >>$here/$seq.full
    echo "<stderr>" >>$here/$seq.full
    ( cat $tmp.err; echo ) >>$here/$seq.full
}

_get_context()
{
    # get a pmapi context reference from pmwebd
    #
    curl -s http://localhost:44323/pmapi/context?hostspec=localhost >$tmp.out 2>$tmp.err
    _dump_curl context
    # get context from a line like in $tmp.out
    # { "context": 2062287553 }
    ( cat $tmp.out; echo ) | $PCP_AWK_PROG '$2 == "\"context\":" { print $3 }'
}

_get_metrics()
{
    # fetch metrics from context $1
    #
    curl -s http://localhost:44323/pmapi/"$1"/_metric?prefix=sample.long >$tmp.out 2>$tmp.err
    _dump_curl metrics
    # metrics are in lines like  ...
    # {"name":"sample.long.one","text-oneline":"1 as a 32-bit integer","text-help":"1 as a 32-bit integer","pmid":121634826,"sem":"instant","units":"","type":"32"},
    ( cat $tmp.out; echo ) \
    | grep '^{"name":' $tmp.out | sed -e 's/"text-help".*/.../' >$tmp.metrics
    if [ -s $tmp.metrics ]
    then
	echo "Got these metrics ..."
	cat $tmp.metrics
    else
	echo "Failed to get metrics ..."
	cat $tmp.out; echo
    fi
}

_stop_auto_restart pmwebd # see GH #394
_service pmwebd stop >/dev/null 2>&1
$sudo $signal -a pmwebd >/dev/null 2>&1

_service pmwebd start
_wait_for_pmwebd 44323

# real QA test starts here
ctx1=`_get_context`
echo "ctx1=$ctx1" >>$here/$seq.full
if [ -z "$ctx1" ]
then
    echo "Arrg, failed to get context number from ..."
    cat $tmp.out; echo
    exit
fi
echo "Got first context number."
_get_metrics $ctx1

# kill off pmcd
echo "Killing off pmcd ..."
_service pmcd stop 2>&1 | _filter_pcp_stop

echo "Retrying first context ..."
_get_metrics $ctx1

ctx2=`_get_context`
echo "ctx2=$ctx2" >>$here/$seq.full
if [ -n "$ctx2" ]
then
    echo "Warning: got second context number from ..."
    cat $tmp.out; echo
    # ok, even though this is wrong (although it used to be that way),
    # let's try and get some metrics ...
    #
    _get_metrics $ctx2
else
    echo "No context number, as expected."
fi

# start pmcd
echo "Restarting pmcd ..."
_service pmcd start 2>&1 | _filter_pcp_stop
_wait_for_pmcd

ctx3=`_get_context`
echo "ctx3=$ctx3" >>$here/$seq.full
if [ -z "$ctx3" ]
then
    echo "Arrg, failed to get context number from ..."
    cat $tmp.out; echo
    exit
fi
echo "Got third context number."
_get_metrics $ctx3

echo "Retrying first context ..."
_get_metrics $ctx1

# success, all done
status=0

exit