[libvirt-users] how virt-manager gets CPU usage of Guest

Michal Privoznik mprivozn at redhat.com
Wed Aug 13 14:55:39 UTC 2014


On 13.08.2014 16:00, Restituto Marcus Arevalo wrote:
> Hi,
>
> Does anybody know how virt-manager is getting the CPU usage of the
> guests? I need to know how to get the CPU usage of the guests and this
> is the only way I can think of. In other words, how does virt-manager
> produce the graph of the CPU usage of EACH guest in KVM? I don't
> actually need the graph, I just need to get the percentage(%) since I'm
> trying to create a Java program to get the CPU usage of each guest in KVM.

This is exactly the question which keeps popping up over and over again. 
So I've written a small demo program which does exactly what you need:

http://libvirt.org/git/?p=libvirt.git;a=blob;f=examples/domtop/domtop.c;h=e50988ed27bdb07702ef437e53eabadb27afe041;hb=HEAD

Have fun with it!

Michal




More information about the libvirt-users mailing list