/var/lib/pcp/testsuite/1041 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 | #!/bin/sh
# PCP QA Test No. 1041
# Exercise the libvirt PMDA - install, remove and values.
#
# Copyright (c) 2016 Red Hat.
#
# Expectations:
# 1) libvirtd installed and running
# - typically from libvirt package
# 2) libvirt Python API available
# - typically from libvirt-python
# 3) optionally one or more VMs up
# 4) libvirt.hv.* metrics always expected
# 5) with VMs available at least:
# - libvirt.dominfo.uuid
# - libvirt.dominfo.name
# - libvirt.dominfo.memory.{boot,current}
# - libvirt.dominfo.vcpu.*
# - libvirt.dominfo.type
# - libvirt.dominfo.os.type
# - libvirt.domstats.mem.*
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.python
[ -d $PCP_PMDAS_DIR/libvirt ] || _notrun "libvirt PMDA directory is not installed"
$python -c "from pcp import pmda" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmda module not installed"
$python -c "import libvirt" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python libvirt module not installed"
_is_libvirt_ok || _notrun "bad python libvirt version"
$python -c "import lxml" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python lxml module not installed"
status=1 # failure is the default!
$sudo rm -rf $tmp.* $seq.full
pmdalibvirt_remove()
{
echo
echo "=== remove libvirt agent ==="
$sudo ./Remove >$tmp.out 2>&1
_filter_pmda_remove <$tmp.out
}
pmdalibvirt_install()
{
# start from known starting points
cd $PCP_PMDAS_DIR/libvirt
$sudo ./Remove >/dev/null 2>&1
cat <<EOF >$tmp.config
[pmda]
#oldapi = False
user = root
uri = qemu:///system
EOF
echo "pmdalibvirt config:" >> $here/$seq.full
cat $tmp.config >> $here/$seq.full
[ -f $PCP_PMDAS_DIR/libvirt/libvirt.conf ] && \
$sudo cp $PCP_PMDAS_DIR/libvirt/libvirt.conf $tmp.backup
$sudo cp $tmp.config $PCP_PMDAS_DIR/libvirt/libvirt.conf
echo
echo "=== libvirt agent installation ==="
$sudo ./Install </dev/null >$tmp.out 2>&1
# Check metrics have appeared ... X metrics and Y values
_filter_pmda_install <$tmp.out \
| sed \
-e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
| $PCP_AWK_PROG '
/Check libvirt metrics have appeared/ { if ($7 >= 67 && $7 <= 250) $7 = "X"
if ($10 >= 14 && $10 <= 50) $10 = "Y"
}
/ warnings, / { if ($9 >= 67 && $9 <= 250) $9 = "X"
if ($12 >= 14 && $12 <= 50) $12 = "Y"
}
{ print }'
}
pmdalibvirt_cleanup()
{
if [ -f $tmp.backup ]; then
$sudo cp $tmp.backup $PCP_PMDAS_DIR/libvirt/libvirt.conf
$sudo rm $tmp.backup
else
$sudo rm -f $PCP_PMDAS_DIR/libvirt/libvirt.conf
fi
# note: _restore_auto_restart pmcd done in _cleanup_pmda()
_cleanup_pmda libvirt
}
_prepare_pmda libvirt
trap "pmdalibvirt_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd
_filter()
{
sed \
-e '/No value(s) available/d' \
#end
}
# real QA test starts here
pmdalibvirt_install
echo
echo "=== verify metric values ==="
echo "from pminfo:" >>$here/$seq.full
pminfo -v libvirt 2>&1 \
| tee -a $here/$seq.full \
| _filter
pmdalibvirt_remove
status=0
exit
|