Product SiteDocumentation Site

3.4.15. getMemoryStats

This method returns the memory statistics for either a single or all and single node (host). It returns a Python list of strings.

Example 3.26. Using getMemoryStats

# Example-26.py
#!/usr/bin/env python3
import sys
import libvirt

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

buf = conn.getMemoryStats(libvirt.VIR_NODE_MEMORY_STATS_ALL_CELLS)

for parm in buf:
    print(parm)

conn.close()
exit(0)