[libvirt] Unable to find node's mem and cpu api

hey, I am unable to find the api in java and perl binding to find the host node's current memory and cpu information. Any body has any idea where I can find the information? - Jovial

On Mon, Sep 01, 2008 at 04:54:04PM +0200, jovialGuy _ wrote:
I am unable to find the api in java and perl binding to find the host node's current memory and cpu information. Any body has any idea where I can find the information?
I'm not certain about whether the Java & Perl bindings support them, but these are the calls you should use: http://libvirt.org/html/libvirt-libvirt.html#virNodeGetInfo http://libvirt.org/html/libvirt-libvirt.html#virNodeGetCellsFreeMemory http://libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory For CPU usage of the host, libvirt doesn't specifically provide that information. If the hypervisor is Xen, then you can get information about CPU usage of Dom0 (usually what is meant by "the host") using: http://libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo but that won't work for QEMU/KVM where "the host node" is just the Linux kernel. (In the local case, you can extract that information you need just by looking in /proc or using ordinary Linux tools). Also read this: http://et.redhat.com/~rjones/virt-top/faq.html#calccpu Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

Great! I have Xen hypervisor. Can I can memory information from "domain 0" instance as well. How to get physical utilization of each CPU attached to host? I know this is being handled in virt-top but how? - Jovial On Mon, Sep 1, 2008 at 5:04 PM, Richard W.M. Jones <rjones@redhat.com>wrote:
On Mon, Sep 01, 2008 at 04:54:04PM +0200, jovialGuy _ wrote:
I am unable to find the api in java and perl binding to find the host node's current memory and cpu information. Any body has any idea where I can find the information?
I'm not certain about whether the Java & Perl bindings support them, but these are the calls you should use:
http://libvirt.org/html/libvirt-libvirt.html#virNodeGetInfo http://libvirt.org/html/libvirt-libvirt.html#virNodeGetCellsFreeMemory http://libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory
For CPU usage of the host, libvirt doesn't specifically provide that information. If the hypervisor is Xen, then you can get information about CPU usage of Dom0 (usually what is meant by "the host") using:
http://libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo
but that won't work for QEMU/KVM where "the host node" is just the Linux kernel. (In the local case, you can extract that information you need just by looking in /proc or using ordinary Linux tools).
Also read this: http://et.redhat.com/~rjones/virt-top/faq.html#calccpu<http://et.redhat.com/%7Erjones/virt-top/faq.html#calccpu>
Rich.
-- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top <http://et.redhat.com/%7Erjonesvirt-top> is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top<http://et.redhat.com/%7Erjones/virt-top>

On Mon, Sep 01, 2008 at 05:26:28PM +0200, jovialGuy _ wrote:
I have Xen hypervisor. Can I can memory information from "domain 0" instance as well.
Yes, although because of the Xen model where dom0 is just a special guest, the amount of memory used by dom0 isn't indicative of the amount of memory available for new guests. Only the hypervisor knows that, and we don't expose it through libvirt [1].
How to get physical utilization of each CPU attached to host? I know this is being handled in virt-top but how?
It's really really complicated. I could explain it here, but that would amount to an imprecise description of what is precisely described in the virt-top code itself. So you're better off just going and reading that code to find out how to do it. http://hg.et.redhat.com/virt/applications/virt-top--devel/?f=ab5dd3923798;fi... lines 595--678. See also the virt-top FAQ: http://et.redhat.com/~rjones/virt-top/faq.html Rich. [1] AFAIK -- perhaps we do through the NUMA calls? -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 64 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
participants (2)
-
jovialGuy _
-
Richard W.M. Jones