Hello, I need to get how much memory is used by a guest system, in order to implement some monitoring function which tells me if the system is overstressed. I am currently using java apis and the binding which was suggested to me was Domain.memoryStats(); This is a binding to int virDomainMemoryStats (virDomainPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainPtr>dom, virDomainMemoryStatPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatPtr>stats, unsigned int nr_stats, unsigned int flags). Problem is that it returns me just tags 0,6 and 7. Looking at the documentation I see they are not what I am looking for...I would rather need 4 (VIR_DOMAIN_MEMORY_STAT_UNUSED) and 5 (VIR_DOMAIN_MEMORY_STAT_AVAILABLE). Is there a way to set them?
Claudio Bley
2014-Mar-14 11:00 UTC
Re: [libvirt-users] Problem in getting memory statistics
At Wed, 12 Mar 2014 13:36:50 +0100, Pasquale Dir wrote:> > Hello, > I need to get how much memory is used by a guest system, in order to > implement some monitoring function which tells me if the system is > overstressed. > > I am currently using java apis and the binding which was suggested to me was > Domain.memoryStats(); > > This is a binding to int virDomainMemoryStats > (virDomainPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainPtr>dom, > virDomainMemoryStatPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatPtr>stats, > unsigned int nr_stats, unsigned int flags). > > Problem is that it returns me just tags 0,6 and 7. > Looking at the documentation I see they are not what I am looking for...I > would rather need 4 (VIR_DOMAIN_MEMORY_STAT_UNUSED) and 5 > (VIR_DOMAIN_MEMORY_STAT_AVAILABLE).The information available depends on the kind of hypervisor you're using and which guest OS you have. I guess you're using qemu. Which version are you using? What guest OS do you use? Which version? What's the version number of the balloon driver inside your guest? [ideally, you should always provide at least the hypervisor and guest OS information without us having to ask you]
Pasquale Dir
2014-Mar-15 22:33 UTC
Re: [libvirt-users] Problem in getting memory statistics
I have another problem. As in java bindings there is no way to obtain cpu stats I decided to use a python script. It gives me, for the guest domain, cpu time, system time and user time. Now, what does it mean cpu time? I though that it could be the overall cpu time given to this vm...but the sum doesn't add up: user_time+system_time != cpu_time. As I would need to get a %cpu usage, like virt-manager does (so it IS possible, and it IS in python), what operation do I need to do to make this happen? 2014-03-12 13:36 GMT+01:00 Pasquale Dir <phate867@gmail.com>:> Hello, > I need to get how much memory is used by a guest system, in order to > implement some monitoring function which tells me if the system is > overstressed. > > I am currently using java apis and the binding which was suggested to me > was > Domain.memoryStats(); > > This is a binding to int virDomainMemoryStats (virDomainPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainPtr>dom, > virDomainMemoryStatPtr<http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatPtr>stats, > unsigned int nr_stats, unsigned int flags). > > Problem is that it returns me just tags 0,6 and 7. > Looking at the documentation I see they are not what I am looking for...I > would rather need 4 (VIR_DOMAIN_MEMORY_STAT_UNUSED) and 5 > (VIR_DOMAIN_MEMORY_STAT_AVAILABLE). > > Is there a way to set them? >
Claudio Bley
2014-Mar-17 08:00 UTC
Re: [libvirt-users] Problem in getting memory statistics
[please don't top post on technical lists. it is easier to follow conversation and less likely you forget answering a question if you reply to the questions in line] [please keep the conversation on the list - I've re-added libvirt-users] At Sat, 15 Mar 2014 10:15:15 +0100, Pasquale Dir wrote:> > I am on a kubuntu 13.10 x64, qemu version 1.5.0, guest uses kvm as emulator > (1.5.0 as well), libvirt version is 1.1.1.> I don't know what is a balloon driver...so I can't tell the version of it.If you're using Linux inside your guest, just run "modinfo virtio_balloon" and post the output.> 2014-03-14 12:00 GMT+01:00 Claudio Bley <cbley@av-test.de>: > > > At Wed, 12 Mar 2014 13:36:50 +0100, > > Pasquale Dir wrote: > > > > > > Problem is that it returns me just tags 0,6 and 7. > > > Looking at the documentation I see they are not what I am looking for...I > > > would rather need 4 (VIR_DOMAIN_MEMORY_STAT_UNUSED) and 5 > > > (VIR_DOMAIN_MEMORY_STAT_AVAILABLE). > > > > The information available depends on the kind of hypervisor you're > > using and which guest OS you have. > > > > I guess you're using qemu. Which version are you using? > > > What guest OS do you use? Which version?Er, you missed this question...
Claudio Bley
2014-Mar-17 08:14 UTC
Re: [libvirt-users] Problem in getting memory statistics
At Sat, 15 Mar 2014 23:33:59 +0100, Pasquale Dir wrote:> > I have another problem. > As in java bindings there is no way to obtain cpu stats I decided to use a > python script. > It gives me, for the guest domain, cpu time, system time and user time. > Now, what does it mean cpu time? I though that it could be the overall cpu > time given to this vm...but the sum doesn't add up: user_time+system_time > != cpu_time. > As I would need to get a %cpu usage, like virt-manager does (so it IS > possible, and it IS in python), what operation do I need to do to make this > happen?Have a look at the implementation of the _sample_cpu_stats method of the vmmDomain class here: https://git.fedorahosted.org/cgit/virt-manager.git/tree/virtManager/domain.py