On Sun, 2014-12-07 at 23:16 -0200, Daniel Henrique Barboza wrote:
I was looking at the following item in the backlog:
Guests Stats: Display memory utilization (use virt-df or virt
-top or ...)
If I understood it right, the idea here is to show the -inner- memory
allocation of the guest. If you have a VM with 4Gb of RAM running an
Ubuntu, we want to know how much memory the Ubuntu OS and its
processes are using.
I've done an investigation and I haven't found any tool to accomplish
this. "virt-top", "virsh dommemstat" and the libvirt API retrieves
the information of the memory usage of the guest relative to the
host. In the example mentioned before, supposing that the host has
64Gb of RAM, all these tools would show that the VM is using 12% of
the host RAM. They do not dive in the VM and shows the actual mem
usage of the Ubuntu and its processes running there.
Haven't found anything useful in other MLs and forums. The common
answer is 'run top in a terminal inside the VM', which of course does
not suit us. My question is: any thoughts about how we can implement
this feature? Because I am starting to think that, in the end, this
kind of info is strict to the guest OS and can't be polled from the
Looking again how to solve this, I could see that virt-manager and
virsh have interfaces to provide the guest's memory usage. For example,
using virsh you can get this kind of information:
$ sudo virsh dommemstat fedora22-mig
This output says that the VM has 2097152 kB allocated and at the moment
when command was executed, it was using 496976 Kb (the rss value).
So, I looked for how those information is provided, and the Libvirt API
provides all necessary information by the https://libvirt.org/html/libv
So, I'm going to work in this tasks and submit patch to provide the
guest's memory usage in back-end. For the moment, I'm planning to
return to following information:
### Resource: Virtual Machine
* **GET**: Retrieve the full description of a Virtual Machine
* name: The name of the VM. Used to identify the VM in this API
* state: Indicates the current state in the VM lifecycle
* running: The VM is powered on
* paused: The VMs virtual CPUs are paused
* shutoff: The VM is powered off
* stats: Virtual machine statistics:
* cpu_utilization: A number between 0 and 100 which indicates
the percentage of CPU utilization.
+ * mem_utilization: A number between 0 and 100 which indicates
+ the percentage of memory utilization.
* net_throughput: Expresses total network throughput for reads
and writes across all virtual interfaces (kb/s).
* net_throughput_peak: The highest recent value of
* io_throughput: Expresses the total IO throughput for reads
and writes across all virtual disks (kb/s).
* io_throughput_peak: The highest recent value of
* uuid: UUID of the VM.
Feedbacks are welcome.
Paulo Ricardo Paz Vital
IBM Linux Technology Center