2.4.5.1 Retrieve Host Statistics Within a Virtual Machine (vm-dump-metrics)

The vm-dump-metrics script can be copied to the guest virtual machine where the message from the ovm_vmhostd script is received. This script is a simple shell script that can output the Oracle VM Server host information in XML format. This XML can be consumed by a SAP application running within the virtual machine.

By default, the vm-dump-metrics script outputs data to STDOUT, but can be changed to output data to file by editing the OUTFILE variable at the beginning of the script.

The vm-dump-metrics script queries ovmd to obtain the message with the key vmhost. If no message is obtained, it exits with status 1. If a message is found, the script parses this message to populate the resulting XML. Typical XML output generated by the vm-dump-metrics script follows:

<metrics>
  <metric type='real64' context='host'>
    <name>TotalCPUTime</name>
    <value>2694.3596</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>PagedOutMemory</name>
    <value>0</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>PagedInMemory</name>
    <value>0</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>UsedVirtualMemory</name>
    <value>6747</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>FreeVirtualMemory</name>
    <value>9817</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>FreePhysicalMemory</name>
    <value>9817</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>MemoryAllocatedToVirtualServers</name>
    <value>6747</value>
  </metric>
  <metric type='uint32' context='host'>
    <name>NumberOfPhysicalCPUs</name>
    <value>4</value>
  </metric>
  <metric type='string' context='host'>
    <name>HostSystemInfo</name>
    <value>ovm3</value>
  </metric>
  <metric type='string' context='host'>
    <name>VirtProductInfo</name>
    <value>Oracle VM 3</value>
  </metric>
  <metric type='string' context='host'>
    <name>VirtualizationVendor</name>
    <value>Oracle Corporation</value>
  </metric>
  <metric type='uint64' context='host'>
    <name>Time</name>
    <value>1360606566774</value>
  </metric>
  <metric type='string' context='host'>
    <name>HostName</name>
    <value>ovm3</value>
  </metric>
  <metric type='uint64' context='vm' id='0' uuid='0004fb00-0006-0000-d72b-647e20a85939'>
    <name>PhysicalMemoryAllocatedToVirtualSystem</name>
    <value>1024</value>
  </metric>
  <metric type='uint64' context='vm' id='0' uuid='0004fb00-0006-0000-d72b-647e20a85939'>
    <name>ResourceMemoryLimit</name>
    <value>1024</value>
  </metric>
  <metric type='uint32' context='vm' id='0' uuid='0004fb00-0006-0000-d72b-647e20a85939'>
    <name>ResourceProcessorLimit</name>
    <value>1</value>
  </metric>
  <metric type='real64' context='vm' id='0' uuid='0004fb00-0006-0000-d72b-647e20a85939'>
    <name>TotalCPUTime</name>
    <value>2694.3596</value>
  </metric>
</metrics>

If you do not want to use the vm-dump-metrics script on your virtual machine, you can query ovmd directly and parse the output yourself:

# ovmd -g vmhost
com.sap.host.VirtualizationVendor=Oracle Corporation;com.sap.host.VirtProductInfo=Oracle VM 3;
com.sap.host.PagedInMemory=0;com.sap.host.PagedOutMemory=0;com.sap.host.PageRates=0;
com.sap.vm.uuid=0004fb0000060000d72b647e20a85939;com.sap.host.HostName=ovm3;
com.sap.host.HostSystemInfo=ovm3;com.sap.host.NumberOfPhysicalCPUs=4;com.sap.host.NumCPUs=4;
com.sap.host.TotalPhyMem=16383;com.sap.host.UsedVirtualMemory=6747;
com.sap.host.MemoryAllocatedToVirtualServers=6747;com.sap.host.FreeVirtualMemory=9817;
com.sap.host.FreePhysicalMemory=9817;com.sap.host.TotalCPUTime=381175.97;
com.sap.host.Time=1360606887997;com.sap.vm.PhysicalMemoryAllocatedToVirtualSystem=1024;
com.sap.vm.ResourceMemoryLimit=1024;com.sap.vm.TotalCPUTime=2696.2214;
com.sap.vm.ResourceProcessorLimit=1;