Will try it out sir! Though I need it in Java but thank you! At least someone replied. Thanks again

Marco


On Wednesday, August 13, 2014 10:55 PM, Michal Privoznik <mprivozn@redhat.com> wrote:


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