From: Michael McCabe Subject: [PATCH] Display Memory Usage Date: Wed, 18 May 2005 14:01:44 -0400 Message-ID: <1116439305.2109.25.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-dTgA4gO8fXcMTNbFJhUa" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-dTgA4gO8fXcMTNbFJhUa Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 Mike --=-dTgA4gO8fXcMTNbFJhUa Content-Disposition: attachment; filename=display-total-mem.patch Content-Type: text/x-patch; name=display-total-mem.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Only in xen-unstable/tools/python: build diff -u -r xen-unstable-orig/tools/python/xen/xm/main.py xen-unstable/tools/python/xen/xm/main.py --- xen-unstable-orig/tools/python/xen/xm/main.py 2005-05-16 13:54:30.000000000 -0400 +++ xen-unstable/tools/python/xen/xm/main.py 2005-05-16 17:43:43.000000000 -0400 @@ -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 --=-dTgA4gO8fXcMTNbFJhUa Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-dTgA4gO8fXcMTNbFJhUa--