Commit b9cfa8ac authored by wonko's avatar wonko

script to determine memory usage

parent 5eed5e2c
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
Created on 26 Feb 2018
@author: wonko
import libvirt
import sys
import os
if __name__ == '__main__':
if 'VIRTURL' in os.environ:
virturl = os.environ['VIRTURL']
virturl = 'qemu+ssh://' + os.environ['USER'] + ''
doms = {}
conn = libvirt.openReadOnly(virturl)
if conn == None:
print ('Failed to open connection to the hypervisor')
for domain in conn.listAllDomains():
i =
doms[] = {
'state': i[0],
'maxmem': i[1],
'mem': i[2],
'vcpu': i[3],
'cputime': i[4]
totalmem = 0
for dom in doms.keys():
maxmem = int(doms[dom]['maxmem']/1024/1024)
print (dom + '\tmaxmem:\t' + str(maxmem) + 'G')
print ('\ttotal memory\t'+ str(totalmem) + 'G')
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment