How to retrieve Memory stat of the KVM using python binding with Libvirt API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi ,
 
I am using ubuntu host machine and KVM is present as guest in that machine.Two virtual machines are there.I am using Python binding to query on the hypervisor and extract the VM related information.I like to print memory stat of the VM  like  SWAP_IN , SWAP_OUT,free memory, mem cached etc.So, the code, I have written for this, is :
 
#!/usr/local/bin/python
import libvirt
import sys

conn = libvirt.openReadOnly(None)
if conn == None:
    print "Failed to open connection to the hypervisor"
    sys.exit(1)

try:
    domIds = conn.listDomainsID()
   
    for id in domIds:
      
        dom0 = conn.lookupByID(id)
       
      
        try:
            print "memory stats: %s"% dom0.memoryStats().values()
        except:
            print 'Failed to find the memory data of this domain'
            sys.exit(1)
     
except:
    print 'Failed to find the main domain'
    sys.exit(1)



But this code 'dom0.memoryStats().values()' is returning empty list.I need to collect more information regarding the memory .How should I proceed?


Regards,
Arpita

[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux