Display Memory Usage
PATCH 1/1 Display Memory Usage
Hi
Here's a simple Display Memory Usage patch that I've written. After some basic testing it appears to be fully functional. I used an unstable tarball yesterday to create the patch, and hope to do more testing once I get my networking issues resolved.
Signed-off-by Michael McCabe <[email protected]>
Mike
Only in xen-unstable/tools/python: build
tools/python/xen/xm/main.py +13 -0
@@ -15,6 +15,7 @@ from xen.xend.XendClient import main as xend_client_main from xen.xm import create, destroy, migrate, shutdown, sysrq from xen.xm.opts import * +from xen.sv.util import * def unit(c): if not c.isalpha():
@@ -383,6 +384,9 @@ self.brief_list(doms) def brief_list(self, doms): + totalused = 0 + totalmem = 0 + totalfree = 0 print 'Name Id Mem(MB) CPU VCPU(s) State Time(s) Console' for dom in doms: info = server.xend_domain(dom)
@@ -390,6 +394,7 @@ d['dom'] = int(sxp.child_value(info, 'id', '-1')) d['name'] = sxp.child_value(info, 'name', '??') d['mem'] = int(sxp.child_value(info, 'memory', '0')) + totalused = totalused + int(sxp.child_value(info, 'memory', '0')) d['cpu'] = int(sxp.child_value(info, 'cpu', '0')) d['vcpus'] = int(sxp.child_value(info, 'vcpus', '0')) d['state'] = sxp.child_value(info, 'state', '??')
@@ -401,9 +406,17 @@ d['port'] = '' print ("%(name)-16s %(dom)3d %(mem)7d %(cpu)3d %(vcpus)5d %(state)5s %(cpu_time)7.1f %(port)4s" % d) + try: + nodeInfo = sxp2hash( server.xend_node() ) + except: + nodeInfo[ 'system' ] = 'Error getting node info' + tmem = memoryFormatter(nodeInfo['memory']) + fmem = memoryFormatter(nodeInfo['free_memory']) + umem = memoryFormatter(totalused) + print "Mem Usage(MB) total "+ tmem + " used: " + umem + " free: " + fmem
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel