memoryStats
method.
Example 4.44. Get the memory statistics
# Example-35.py #!/usr/bin/env python3 import sys import libvirt domName = 'Fedora22-x86_64-1' conn = None try: conn = libvirt.open("qemu:///system") except libvirt.libvirtError as e: print(repr(e), file=sys.stderr) exit(1) dom = conn.lookupByID(5) if dom == None: print('Failed to find the domain '+domName, file=sys.stderr) exit(1) stats = dom.memoryStats() print('memory used:') for name in stats: print(' '+str(stats[name])+' ('+name+')') conn.close() exit(0)
memoryStats
returns a dictionary object. This object will contain a variable number of entries depending on the hypervisor and guest domain capabilities.