Hi everybody, I'm using the PHP API to make a web interface interact with the virtual machines installed on some hypervisor. Everything is fine, but I would like to find a way to get the guest's cpu and mem usage, so that it should be possible to make some rrd graphs. I didn't find out anything and also it seems looking around that there is no way to obtain those data. What is strange for me is that programs like virt-top are showing exactly what I'm looking for. Can anyone help me to find out a way to retrieve those statistics? Another related question: do you think I can obtain the same data by using this: ps aux | egrep "[/]usr/libexec/qemu-kvm.*libvirt.*" | awk '{print $3"/"$4}' on the hypervisor? These are related to the kvm process, and the kvm process IS the virtual machine... Or not? Thanks to everybody, -- RaSca Mia Mamma Usa Linux: Niente ? impossibile da capire, se lo spieghi bene! rasca at miamammausalinux.org http://www.miamammausalinux.org
Daniel P. Berrange
2012-Apr-12 08:30 UTC
[libvirt-users] No way to obtain guest's cpu and mem usage?
On Thu, Apr 12, 2012 at 09:21:18AM +0200, RaSca wrote:> Hi everybody, > I'm using the PHP API to make a web interface interact with the virtual > machines installed on some hypervisor. > Everything is fine, but I would like to find a way to get the guest's > cpu and mem usage, so that it should be possible to make some rrd > graphs. I didn't find out anything and also it seems looking around that > there is no way to obtain those data. > > What is strange for me is that programs like virt-top are showing > exactly what I'm looking for. Can anyone help me to find out a way to > retrieve those statistics?virt-top mostly uses the virDomainGetInfo() API to get this data. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Michal Privoznik
2012-Apr-12 09:08 UTC
[libvirt-users] No way to obtain guest's cpu and mem usage?
On 12.04.2012 09:21, RaSca wrote:> Hi everybody, > I'm using the PHP API to make a web interface interact with the virtual > machines installed on some hypervisor. > Everything is fine, but I would like to find a way to get the guest's > cpu and mem usage, so that it should be possible to make some rrd > graphs. I didn't find out anything and also it seems looking around that > there is no way to obtain those data. > > What is strange for me is that programs like virt-top are showing > exactly what I'm looking for. Can anyone help me to find out a way to > retrieve those statistics? > > Another related question: do you think I can obtain the same data by > using this: > > ps aux | egrep "[/]usr/libexec/qemu-kvm.*libvirt.*" | awk '{print $3"/"$4}' >This takes into account memory used by hypervisor itself. Either you need to extend libvirt-php; or you can do: $stats = exec("virsh dommemstat $dom"); However, I lean towards libvirt-php extension. Michal