[libvirt] How to get VM memory usage

Hello everyone, Could you tell me how to get VM memory usage from libvirt-go? Thanks wangyufeng@cloudguarding.com

On Thu, Apr 20, 2017 at 09:33:12AM +0800, wangyufeng@cloudguarding.com wrote:
Hello everyone,
Could you tell me how to get VM memory usage from libvirt-go?
The virDomainGetInfo() method includes memory data. Thi is the 'GetInfo()' method on a Domain object in Go Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Hi Daniel, In method 'GetInfo', we can only get memory and max memory. However I need to get used memory for calculating memory usage. The virsh command 'dommemstat' can obtain used memory, is there a method in libvirt-go to obtain used memory? Regards, Yufeng wangyufeng@cloudguarding.com From: Daniel P. Berrange Date: 2017-04-20 16:13 To: wangyufeng@cloudguarding.com CC: libvir-list Subject: Re: [libvirt] How to get VM memory usage On Thu, Apr 20, 2017 at 09:33:12AM +0800, wangyufeng@cloudguarding.com wrote:
Hello everyone,
Could you tell me how to get VM memory usage from libvirt-go?
The virDomainGetInfo() method includes memory data. Thi is the 'GetInfo()' method on a Domain object in Go Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, Apr 21, 2017 at 09:58:12AM +0800, wangyufeng@cloudguarding.com wrote:
Hi Daniel,
In method 'GetInfo', we can only get memory and max memory. However I need to get used memory for calculating memory usage. The virsh command 'dommemstat' can obtain used memory, is there a method in libvirt-go to obtain used memory?
That command uses the virDomainMemoryStats() API call Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrange
-
wangyufeng@cloudguarding.com