[libvirt] Current cpu and memory usage for Host and Domains

Hi, Is there a way to get the Current CPU and Memory usage of the Host machine and the Guest Domains..?? Regards Anuj

On Thu, Dec 17, 2009 at 06:26:41PM +0530, anuj rampal wrote:
Hi,
Is there a way to get the Current CPU and Memory usage of the Host machine and the Guest Domains..??
See http://libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo and http://libvirt.org/html/libvirt-libvirt.html#virDomainInfo plus the mails exchanged on the subject in the last few days ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Seem there is no way to get host CPU usage in libvirt API? I can get freeMemory by virNodeGetFreeMemory, but no cpu usage API. How about add a new api for it? The host CPU usage is also important for VM creation and migration decision, like the free memory. Yes, I know, I can got it from "top"...:) On Thu, Dec 17, 2009 at 5:06 AM, Daniel Veillard <veillard@redhat.com>wrote:
On Thu, Dec 17, 2009 at 06:26:41PM +0530, anuj rampal wrote:
Hi,
Is there a way to get the Current CPU and Memory usage of the Host machine and the Guest Domains..??
See http://libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo and http://libvirt.org/html/libvirt-libvirt.html#virDomainInfo
plus the mails exchanged on the subject in the last few days !
Daniel
-- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Jan 15, 2010 at 11:52:09AM -0800, su disheng wrote:
Seem there is no way to get host CPU usage in libvirt API? I can get freeMemory by virNodeGetFreeMemory, but no cpu usage API. How about add a new api for it? The host CPU usage is also important for VM creation and migration decision, like the free memory. Yes, I know, I can got it from "top"...:)
We've historically thought that monitoring of the host OS is out of scope of the libvirt API, since there are already a huge variety of monitoring services / APIs available for people. I wonder if we need to reconsider that now we have the VMWare drivers though - apps using libvirt don't get to installl stuff in VMWare host OS, so the only access to some of this host CPU data is probably via the VMWare APIs. Which in turn suggests we'd need to expose some minimal hosting API for this in libvirt FWIW, virt-top/virt-manager calculates host CPU usage by summing the usage of all guests over a fixed time slice. This will be an underestimate of true host utilization though, since it can't see CPU usage for non-guest related processes Daniel -- |: Red Hat, Engineering, London -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 Sun, Jan 17, 2010 at 01:02:33PM +0000, Daniel P. Berrange wrote:
On Fri, Jan 15, 2010 at 11:52:09AM -0800, su disheng wrote:
Seem there is no way to get host CPU usage in libvirt API? I can get freeMemory by virNodeGetFreeMemory, but no cpu usage API. How about add a new api for it? The host CPU usage is also important for VM creation and migration decision, like the free memory. Yes, I know, I can got it from "top"...:)
We've historically thought that monitoring of the host OS is out of scope of the libvirt API, since there are already a huge variety of monitoring services / APIs available for people. I wonder if we need to reconsider that now we have the VMWare drivers though - apps using libvirt don't get to installl stuff in VMWare host OS, so the only access to some of this host CPU data is probably via the VMWare APIs. Which in turn suggests we'd need to expose some minimal hosting API for this in libvirt
I think in both case it boils down to be able to rely on a single access method for the monitoring of virtualization and host capacity, the pressure has increased with usage or remote access and new hypervisors. It's not like providing those new APIs would be hard, but we still have pure virtualization code to focuse on, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Sun, Jan 17, 2010 at 5:02 AM, Daniel P. Berrange <berrange@redhat.com>wrote:
On Fri, Jan 15, 2010 at 11:52:09AM -0800, su disheng wrote:
Seem there is no way to get host CPU usage in libvirt API? I can get freeMemory by virNodeGetFreeMemory, but no cpu usage API. How about add a new api for it? The host CPU usage is also important for VM creation and migration decision, like the free memory. Yes, I know, I can got it from "top"...:)
We've historically thought that monitoring of the host OS is out of scope of the libvirt API, since there are already a huge variety of monitoring services / APIs available for people. I wonder if we need to reconsider that now we have the VMWare drivers though - apps using libvirt don't get to installl stuff in VMWare host OS, so the only access to some of this host CPU data is probably via the VMWare APIs. Which in turn suggests we'd need to expose some minimal hosting API for this in libvirt
Like this happened in the future, one APIs for both host and guest. Especially, for KVM, there is no much difference to get the both host and guest, cpu/disk/nic statistic data.
FWIW, virt-top/virt-manager calculates host CPU usage by summing the usage of all guests over a fixed time slice. This will be an underestimate of true host utilization though, since it can't see CPU usage for non-guest related processes
For Xen like hypervisors, by summing the usage of all guests is OK, but for KVM, it's better to include other non-guest related processes.
Daniel -- |: Red Hat, Engineering, London -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/<http://search.cpan.org/%7Edanberr/>:| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (4)
-
anuj rampal
-
Daniel P. Berrange
-
Daniel Veillard
-
su disheng