Commit b9cfa8ac authored by wonko's avatar wonko

script to determine memory usage

parent 5eed5e2c
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>plumbing</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?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">
<path>/${PROJECT_DIR_NAME}/src</path>
</pydev_pathproperty>
<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>
</pydev_project>
'''
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']
else:
virturl = 'qemu+ssh://' + os.environ['USER'] + '@gallifrey.chaos.expert/system'
doms = {}
conn = libvirt.openReadOnly(virturl)
if conn == None:
print ('Failed to open connection to the hypervisor')
sys.exit(1)
for domain in conn.listAllDomains():
i = domain.info()
doms[domain.name()] = {
'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')
totalmem+=maxmem
print ('\ttotal memory\t'+ str(totalmem) + 'G')
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment