Guido Winkelmann
2011-Jan-19 16:18 UTC
[libvirt-users] Getting CPU and memory usage statistics for the host
Hi, I have noticed that virt-manager has the ability to show me the current cpu- and memory-usage of both the host and running guest machines. How does it do that? I could make good use of that information myself in the client applications I'm writing, however, from what I can see on http://libvirt.org/html/libvirt-libvirt.html, I have no idea how to go about getting it from libvirt. In fact, before I've seen virt-manager, I just assumed libvirt cannot do that at all, and was planning to manually ssh to the host and read statistics from /proc when I'd need them. I've tried looking at the virt-manager source code to find out how to do this, but it appears I would have to learn Python first in order to understand it. Could someone please give me some pointers? Regards, Guido
Peter Phaal
2011-Jan-19 18:00 UTC
[libvirt-users] Getting CPU and memory usage statistics for the host
If your client application is being written in C, you might want to take a look at the Host sFlow source code: http://host-sflow.sourceforge.net/ The Host sFlow agent locally polls counters using libvirt and then exports them using the sFlow protocol. You might want to think about adding sFlow support to your application. Passively receiving the counters over UDP is simpler and more scalable than counter polling. You can also use sFlow to monitor the physical server statistics and traffic through the virtual switch to get a complete picture of performance. http://blog.sflow.com/2010/10/sflowtrend-adds-server-performance.html On Wed, Jan 19, 2011 at 8:18 AM, Guido Winkelmann <guido-libvi at unknownsite.de> wrote:> Hi, > > I have noticed that virt-manager has the ability to show me the current cpu- and > memory-usage of both the host and running guest machines. > > How does it do that? > > I could make good use of that information myself in the client applications I'm > writing, however, from what I can see on > http://libvirt.org/html/libvirt-libvirt.html, I have no idea how to go about > getting it from libvirt. In fact, before I've seen virt-manager, I just assumed > libvirt cannot do that at all, and was planning to manually ssh to the host and > read statistics from /proc when I'd need them. > > I've tried looking at the virt-manager source code to find out how to do this, > but it appears I would have to learn Python first in order to understand it. > > Could someone please give me some pointers? > > Regards, > > ? ? ? ?Guido > > _______________________________________________ > libvirt-users mailing list > libvirt-users at redhat.com > https://www.redhat.com/mailman/listinfo/libvirt-users >