/var/lib/pcp/testsuite/common.prometheus is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o644.
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 | #
# Common shell routines for testing pmdaprometheus
#
# Copyright (c) 2017 Red Hat.
#
# get standard environment, filters and checks
. ./common.python
CONFIG_DIR=$PCP_PMDAS_DIR/prometheus/config.d
_pmdaprometheus_check()
{
[ -f $PCP_PMDAS_DIR/prometheus/pmdaprometheus.python ] || return 1
[ -f $here/prometheus/prometheus_endpoint.python ] || return 1
return 0
}
_have_python266()
{
v=`python -V 2>&1 | awk '{print $NF}'`
[ "$v" = "2.6.6" ] && return 0
return 1
}
_pmdaprometheus_remove()
{
echo
echo "=== remove prometheus agent ==="
cd $PCP_PMDAS_DIR/prometheus
$sudo ./Remove >$tmp.out 2>&1
_filter_pmda_remove <$tmp.out
}
_pmdaprometheus_install()
{
# start from known starting points
cd $PCP_PMDAS_DIR/prometheus
$sudo ./Remove >/dev/null 2>&1
_service pmcd stop 2>&1 | _filter_pcp_stop
echo
echo "=== prometheus agent installation ==="
$sudo ./Install </dev/null >$tmp.out 2>&1
cat $tmp.out >>$here/$seq.full
}
_pmdaprometheus_save_config()
{
$sudo rm -rf $CONFIG_DIR.$seq
$sudo mv $CONFIG_DIR $CONFIG_DIR.$seq
$sudo mkdir -p $CONFIG_DIR
$sudo chmod 777 $CONFIG_DIR
for f in $PCP_VAR_DIR/config/pmda/144.*.py; do
[ -f "$f" ] && $sudo mv -f $f $f.$seq
done
}
_pmdaprometheus_restore_config()
{
$sudo rm -rf $CONFIG_DIR
$sudo mv $CONFIG_DIR.$seq $CONFIG_DIR
$sudo chmod 755 $CONFIG_DIR
$sudo rm -f $PCP_VAR_DIR/config/pmda/144.*.py
for f in $PCP_VAR_DIR/config/pmda/144.*.py.$seq; do
[ -f "$f" ] && $sudo mv -f $f `echo $f | sed -e "s/\.$seq//"`
done
}
# wait for the PMDA to dynamically create a named metric (or subtree)
_pmdaprometheus_wait_for_metric()
{
metric="$1"
configdir="$2"
[ -z "$metric" ] && metric=prometheus.control.calls
[ -z "$configdir" ] && configdir=$CONFIG_DIR
# wait for the requested metric to appear in the pmns
_i=0
while [ $_i -lt 30 ]
do
if pminfo $metric >/dev/null 2>&1
then
# all good
return 0
fi
sleep 1
_i=`expr $_i + 1`
done
# timeout, fail
echo _pmdaprometheus_wait_for_metric FAILED for metric $metric
return 1
}
|