[Libvir] How to get the memory used by a guest domin

Hi, It appears to be no API available to provide the memory used by a guest domin. I looked at the availble libvirt api called "virNodeGetCellsFreeMemory" using which it is possible to get the free mem. But looking further I found that this is free memory of the "whole box" rather than based upon the guest domain. How can I get the memory used by a guest domin. Thanks n Regards, -Pranay.

On Wed, Apr 30, 2008 at 05:45:55PM +0530, Pranay Prasoon wrote:
Hi, It appears to be no API available to provide the memory used by a guest domin. I looked at the availble libvirt api called "virNodeGetCellsFreeMemory" using which it is possible to get the free mem. But looking further I found that this is free memory of the "whole box" rather than based upon the guest domain. How can I get the memory used by a guest domin.
virDomainGetInfo() It fills in a virDomainInfo struct with unsigned long maxMem; /* the maximum memory in KBytes allowed */ unsigned long memory; /* the memory in KBytes used by the domain */ Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Hi dan, I got confused with your answer, virDomainInfo memory, Does it mean that all allocated memory is utilized by the guest OS? Their is good chance that Guest OS may not be utilizing all memory. How to find out the Currently running Guest Domains memory utilization level? On Wed, 2008-04-30 at 13:18 +0100, Daniel P. Berrange wrote:y
On Wed, Apr 30, 2008 at 05:45:55PM +0530, Pranay Prasoon wrote:
Hi, It appears to be no API available to provide the memory used by a guest domin. I looked at the availble libvirt api called "virNodeGetCellsFreeMemory" using which it is possible to get the free mem. But looking further I found that this is free memory of the "whole box" rather than based upon the guest domain. How can I get the memory used by a guest domin.
virDomainGetInfo()
It fills in a virDomainInfo struct with
unsigned long maxMem; /* the maximum memory in KBytes allowed */ unsigned long memory; /* the memory in KBytes used by the domain */
Dan.
Thanks & Regards --Ajish

On Wed, Apr 30, 2008 at 06:37:26PM +0530, ajishrao wrote:
Hi dan,
I got confused with your answer, virDomainInfo memory,
Does it mean that all allocated memory is utilized by the guest OS?
No, this just tells you how much memory the hypervisor has allocated to the guest OS.
Their is good chance that Guest OS may not be utilizing all memory.
Correct. The only way to find that out is to ask the guest OS for its fine grained breakdown of memory usage. The hypervisor/host OS doesn't have ability to get this information.
How to find out the Currently running Guest Domains memory utilization level?
You'll want to have some monitoring agent inside your guest OS. One example lightweight agent is 'collected'. It'll transmit utilization data to any host over the network where you can analyse it Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Apr 30, 2008 at 01:57:21PM +0100, Daniel P. Berrange wrote:
You'll want to have some monitoring agent inside your guest OS. One example lightweight agent is 'collected'. It'll transmit utilization data to any
Dan means collectd, from http://collectd.org/ I'll emphasize what Dan said: The only way to reliably get things like real memory usage, process lists and so on from the guest is to run some agent/program inside the guest. This is how VMWare does it. I've been chipping away at these restrictions, because I think it'd be useful for sysadmins to be able to see guest status from the dom0 without needing to install software in the guests. For disk usage, we now have virt-df (http://et.redhat.com/~rjones/virt-df/) which runs entirely in the dom0. Virt-df works by parsing the guest's disk image -- a hard but tractable problem that turns out to give pretty reliable results in most scenarios. However for getting guest memory / process lists the situation is much more complicated. You'd need to peek into the guest's memory and read kernel structures, a very complex problem indeed (and not even tractable on a certain popular closed-source operating system). A more tractable alternative is to run an agent in the guest which is common and widely available, such as a simple kernel module that shares data over a common host <-> guest bus. It would be kind of like virtio [http://lwn.net/Articles/239238/] for monitoring. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (4)
-
ajishrao
-
Daniel P. Berrange
-
Pranay Prasoon
-
Richard W.M. Jones