3 # Exercise the libvirt PMDA - install, remove and values.
5 # Copyright (c) 2016 Red Hat.
8 # 1) libvirtd installed and running
9 # - typically from libvirt package
10 # 2) libvirt Python API available
11 # - typically from libvirt-python
12 # 3) optionally one or more VMs up
13 # 4) libvirt.hv.* metrics always expected
14 # 5) with VMs available at least:
15 # - libvirt.dominfo.uuid
16 # - libvirt.dominfo.name
17 # - libvirt.dominfo.memory.{boot,current}
18 # - libvirt.dominfo.vcpu.*
19 # - libvirt.dominfo.type
20 # - libvirt.dominfo.os.type
21 # - libvirt.domstats.mem.*
25 echo "QA output created by $seq"
29 [ -d $PCP_PMDAS_DIR/libvirt
] || _notrun
"libvirt PMDA directory is not installed"
30 $python -c "from pcp import pmda" >/dev
/null
2>&1
31 [ $?
-eq 0 ] || _notrun
"python pcp pmda module not installed"
32 $python -c "import libvirt" >/dev
/null
2>&1
33 [ $?
-eq 0 ] || _notrun
"python libvirt module not installed"
34 $python -c "import lxml" >/dev
/null
2>&1
35 [ $?
-eq 0 ] || _notrun
"python lxml module not installed"
37 status
=1 # failure is the default!
38 $sudo rm -rf $tmp.
* $seq.full
43 echo "=== remove libvirt agent ==="
44 $sudo .
/Remove
>$tmp.out
2>&1
45 _filter_pmda_remove
<$tmp.out
50 # start from known starting points
51 cd $PCP_PMDAS_DIR/libvirt
52 $sudo .
/Remove
>/dev
/null
2>&1
53 $sudo $PCP_RC_DIR/pmcd stop
55 cat <<EOF >$tmp.config
61 echo "pmdalibvirt config:" >> $here/$seq.full
62 cat $tmp.config
>> $here/$seq.full
64 [ -f $PCP_PMDAS_DIR/libvirt
/libvirt.conf
] && \
65 $sudo cp $PCP_PMDAS_DIR/libvirt
/libvirt.conf
$tmp.backup
66 $sudo cp $tmp.config
$PCP_PMDAS_DIR/libvirt
/libvirt.conf
69 echo "=== libvirt agent installation ==="
70 $sudo .
/Install
</dev
/null
>$tmp.out
2>&1
71 # Check metrics have appeared ... X metrics and Y values
72 _filter_pmda_install
<$tmp.out \
74 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
76 /Check libvirt metrics have appeared/ { if ($7 >= 67 && $7 <= 100) $7 = "X"
77 if ($10 >= 14 && $10 <= 50) $10 = "Y"
79 / warnings, / { if ($9 >= 67 && $9 <= 100) $9 = "X"
80 if ($12 >= 14 && $12 <= 50) $12 = "Y"
87 if [ -f $tmp.backup
]; then
88 $sudo cp $tmp.backup
$PCP_PMDAS_DIR/libvirt
/libvirt.conf
91 $sudo rm -f $PCP_PMDAS_DIR/libvirt
/libvirt.conf
97 trap "pmdalibvirt_cleanup; exit \$status" 0 1 2 3 15
102 -e '/No value(s) available/d' \
106 # real QA test starts here
110 echo "=== verify metric values ==="
111 echo "from pminfo:" >>$here/$seq.full
112 pminfo
-v libvirt
2>&1 \
113 |
tee -a $here/$seq.full \