diff -r 846510a73535 -r 8bf13358a50a relpipe-data/examples-in-xmltable-libvirt.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relpipe-data/examples-in-xmltable-libvirt.xml Thu Jul 25 22:16:12 2019 +0200 @@ -0,0 +1,139 @@ + + + Reading Libvirt XML files using XMLTable + converting arbitrary XML into one or more relations + 02700 + + + +

+ Libvirt is a popular API/tool for managing virtual machines (KVM/Qemu, LXC etc.) and stores its configuration in XML files. + Thanks to the tool relpipe-in-xmltable we can get aggregated overview of our virtual machines. + This tool does similar job like the xmltable function known from SQL. + It uses the XPath language for selecting parts of the input XML – one XPath expression points to record nodes + and one or more XPath expressions point to attribute nodes/values relatively to particular record node. + Our tool is able to produce one or more relations from a single XML input. + The input is parsed at once and converted to DOM in memory i.e. no streaming – thus processing of huge XML files requires appropriate amounts of RAM, on the other hand: + our expression can access whole XML document and pick values not only from currently processed record node. +

+ + +

These XML config files contain lot of information describing given virtual machine:

+ + + + + relpipe-1 + 36d1e8b2-97e9-40cb-9fc2-306ebf989282 + 1048576 + 1048576 + 2 + + hvm + + + + + + + + + Opteron_G5 + + + + + + + … + + /usr/bin/kvm-spice + + + + +
+ + + + + +
+ + … + + + + +
+ + … + +]]> + + +

If we are interested only in certain parts, we can pick them using a command like this one:

+ + + + +

And get three relations:

+ +
+ +

+ Each record contain ID of the machine, thus if we collect data from several VMs, + we can JOIN relevant records together, do some aggregations or statistics. + If we are sure that the name field is unique, we can use it as a key instead of the UUID. +

+ + + + +