[libvirt-users] Problem in getting memory statistics

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?

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]

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?

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.p...
participants (2)
-
Claudio Bley
-
Pasquale Dir