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"
27 # get standard environment, filters and checks
32 export PCP_PMDAS_DIR
=/var
/lib
/pcp
/pmdas
34 [ -d $PCP_PMDAS_DIR/libvirt
] || _notrun
"libvirt PMDA directory is not installed"
36 status
=1 # failure is the default!
37 $sudo rm -rf $tmp.
* $seq.full
42 echo "=== remove libvirt agent ==="
43 $sudo .
/Remove
>$tmp.out
2>&1
44 _filter_pmda_remove
<$tmp.out
49 # start from known starting points
50 cd $PCP_PMDAS_DIR/libvirt
51 $sudo .
/Remove
>/dev
/null
2>&1
52 $sudo $PCP_RC_DIR/pmcd stop
54 cat <<EOF >$tmp.config
60 echo "pmdalibvirt config:" >> $here/$seq.full
61 cat $tmp.config
>> $here/$seq.full
63 [ -f $PCP_PMDAS_DIR/libvirt
/libvirt.conf
] && \
64 $sudo cp $PCP_PMDAS_DIR/libvirt
/libvirt.conf
$tmp.backup
65 $sudo cp $tmp.config
$PCP_PMDAS_DIR/libvirt
/libvirt.conf
68 echo "=== libvirt agent installation ==="
69 $sudo .
/Install
</dev
/null
>$tmp.out
2>&1
70 # Check metrics have appeared ... X metrics and Y values
71 _filter_pmda_install
<$tmp.out \
73 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
75 /Check libvirt metrics have appeared/ { if ($7 >= 67 && $7 <= 67) $7 = "X"
76 if ($10 >= 14 && $10 <= 50) $10 = "Y"
78 / warnings, / { if ($9 >= 67 && $9 <= 67) $9 = "X"
79 if ($12 >= 14 && $12 <= 50) $12 = "Y"
86 if [ -f $tmp.backup
]; then
87 $sudo cp $tmp.backup
$PCP_PMDAS_DIR/libvirt
/libvirt.conf
90 $sudo rm -f $PCP_PMDAS_DIR/libvirt
/libvirt.conf
96 trap "pmdalibvirt_cleanup; exit \$status" 0 1 2 3 15
98 # real QA test starts here
102 echo "=== extract metric values ==="
103 echo "from pmprobe:" >>$here/$seq.full
105 | LC_COLLATE
=POSIX
sort