[libvirt-users] Fwd: How to get guest's cpu and mem usage with Java APIs

Claudio Bley cbley at av-test.de
Tue Mar 11 07:40:55 UTC 2014


At Mon, 10 Mar 2014 21:38:21 +0100,
Enrico De Maio wrote:
> 
> I would like to know how much memory and cpu virtual machine are using so
> yes guest's perspective.

See Domain.memoryStats[1] for retrieving memory statistics about a
domain. AFAIK, the stats returned depend upon the guest OS and whether
you have some guest additions (ie. the balloon driver for qemu)
installed.

There's currently no way of retrieving the CPU stats of a domain from
Java. (patches welcome)

[1]: http://libvirt.org/sources/java/javadoc/org/libvirt/Domain.html#memoryStats(int)

> I'm building a web app that has to alert the user when the vm is
> going to be stressed and I would like to do this in terms of mem and
> cpu usage.
> 
> Thanks in advance for your support,
> 
> Enrico De Maio
> 
> 
> On Mon, Mar 10, 2014 at 7:16 PM, Eric Blake <eblake at redhat.com> wrote:
> 
> > On 03/10/2014 04:54 AM, Enrico De Maio wrote:
> > > Hi everybody,
> > >
> > > I'm using libvirt java api bindings for my thesis. I would like to know
> > if
> > > there is a way to obtain live information about cpu and mem usage of a
> > > domain.
> >
> > Are you asking the question from the host's perspective (how much
> > resources has the host given to the guest) or from the guest's
> > perspective (how much is the guest actively using, even if the host has
> > given it more)?  Libvirt already provides several API calls. such as the
> > ones used by 'virsh cpu-stats' and 'virsh dommemstat'; you may have to
> > do some code reading to figure out what C calls the virsh code made in
> > order to find the same API under the Java bindings.
> >
> > --
> > Eric Blake   eblake redhat com    +1-919-301-3266
> > Libvirt virtualization library http://libvirt.org
> >
> >
-- 
BSc (Comp) Claudio Bley - Principal Software Engineer
AV-TEST GmbH, Klewitzstr. 7, 39112 Magdeburg, Germany
Phone: +49 391 6075460, Fax: +49 391 6075469
Web: <http://www.av-test.org>

* https://twitter.com/avtestorg * https://facebook.com/avtestorg *
* https://plus.google.com/100383867141221115206/ *

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

Our services shall be effected on the basis of the General Terms
and Conditions of AV-TEST GmbH, which are accessible under
<http://www.av-test.org/en/av-test/terms-and-conditions/> or
obtainable upon request.

Unsere Leistungen erfolgen auf der Grundlage der Allgemeinen
Geschäftsbedingungen der AV-TEST GmbH, die unter
<http://www.av-test.org/av-test/agb/> abrufbar sind oder auf
Anfrage übersandt werden.




More information about the libvirt-users mailing list