This documentation supports releases of BMC Helix Continuous Optimization up to December 31, 2021. To view the latest version, select the version from the Product version menu.

Collecting memory utilization metrics from KVM virtual machines


You can use the Agent to collect memory utilization metrics from KVM virtual machines. To enable the KVM hypervisor to provide these metrics, you must run the dommemstat command as follows:

  1. Log in to your KVM host.
  2. Verify whether the dommemstat version supports the --period <number> option by running the following command. This option is required for enabling the metrics.
    virsh help dommemstat
  3. Verify whether the following results are displayed that indicate support for the --period <number> option:
    NAME

    dommemstat - get memory statistics for a domain

    SYNOPSIS
    dommemstat <domain> [--period <number>] [--config] [--live] [--current]

    DESCRIPTION
    Get memory statistics for a running domain.

    OPTIONS
    [--domain] <string> domain name, id or uuid
    --period <number> period in seconds to set collection
    --config affect next boot
    --live affect running domain
    --current affect current domain

  4. Run the following command to enable the metrics:
    virsh dommemstat <ID> --period 10 --live
    where, ID indicates the ID or name of the KVM.
  5. Verify that the metrics are enabled by running the following command:
    virsh -c qemu:///system --readonly dommemstat <ID| Name of VM>
    where ID is a domain name. To view a list of available domains, run the virsh list command.
    If the KVM is collecting memory statistics, it displays metrics similar to the following:
    swap_in

    swap_out

    major_fault

    minor_fault

    unused

    available

    usable

     If the KVM is not collecting memory statistics, it displays metrics similar to the following:

     actual

    last_update

    rss

  6. Verify that both the available and unused metrics are displayed and show non-zero values.

    Additional examples

    To list current VMs:

    $ virsh -c qemu:///system --readonly list

    To check the memory statistics for all current running VMs:

    $ for ID in `virsh -c qemu:///system --readonly list | grep running | cut -d ' ' -f 2`;do echo "ID = $ID";virsh -c qemu:///system --readonly dommemstat $ID;done

    ID = 14

    actual 16777216

    swap_in 0

    swap_out 0

    major_fault 45249

    minor_fault 789565533

    unused 15374012

    available 16257500

    usable 15629308

    last_update 1622572158

    rss 1574076

     

    ID = 15

    actual 8388608

    last_update 0

    rss 8457856

     

    ID = 17

    actual 16777216

    swap_in 0

    swap_out 0

    major_fault 42413

    minor_fault 790621492

    unused 15348592

    available 16257500

    usable 15646232

    last_update 1622572157

    rss 1692932

    In this example, VMs 14 and 17 are collecting memory statistics, VM 15 is not collecting memory statistics (it is running on Windows). Note that VMs running Windows will not be able to be successfully configured to collect memory statistics.

    To configure any individual VM to collect memory statistics requires root permissions:

    $ su root -c “virsh -c qemu:///system dommemstat <ID|Name of VM> --period 10 --live"

    To configure all running VMs to collect memory statistics:

    $ su root
    $ for ID in `virsh -c qemu:///system --readonly list | grep running | cut -d ' ' -f 2`;do echo "ID = $ID";virsh -c qemu:///system dommemstat $ID --period 10 --live;done

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*