WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] Measuring overall CPU utlization

To: "John A. Sullivan III" <jsullivan@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-users] Measuring overall CPU utlization
From: "Diwaker Gupta" <diwaker.lists@xxxxxxxxx>
Date: Wed, 26 Apr 2006 14:07:49 -0700
Cc: Peter Fokkinga <peter@xxxxxxxxxxx>, xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 26 Apr 2006 14:08:23 -0700
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TqiFIloP2Z0afNa43bbJjK7aeDV/NrychHpSj8Z+raXkrl3DlxchJvv9GzMc45mq/h+lHIdovo+bvSu16nDMG07i7//J71FXYFUPxtiV1YQPDRXDM6tNXtM7qJANHeIV22rlGzduvrfXWNpywCjtYhq+mM7y91yD3PULC5Dea8s=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1146079476.2991.83.camel@localhost>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <1146077905.2991.79.camel@localhost> <20060426210346.cs3bqjt1k7c4g0sk@xxxxxxxxxxxxxxxx> <1146079476.2991.83.camel@localhost>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
> <snip>
> I'm sorry; I should have specified that I am running Xen 2.0.7.  I do
> not see or have a xm top command.  What do I do in 2.0.7?

This works for me in Xen 2.0.7 (or you can write a wrapper around 'xm
list'). This is not guaranteed to be correct/accurate -- you at your
own risk :-) :

====================================
import sys
import curses
import curses.ascii
import time

sys.path.append('/usr/lib/python')
import xen.lowlevel.xc

xc = xen.lowlevel.xc.new()

# initialize curses
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)

# timeout getch after 1s
stdscr.timeout(1000)

(maxy, maxx) = stdscr.getmaxyx()

vtop_start = time.time()
first_run = True

shares = {}
while True:
    # sleep for 1 second
    # between outputs
    dlist = xc.domain_getinfo()
    idx = 1
    cpusum=0
    if first_run:
        for d in dlist:
            shares[d['dom']] = d['cpu_time']
        first_run = False
    else:
        for d in dlist:
            now = time.time()
            share = d['cpu_time'] - shares[d['dom']]
            p = (share*100)/((now - vtop_start) * 10**9)
            cpusum+=p
            stdscr.addstr(idx, 1, "%d\t\t%d\t\t%.2f" % (d['dom'], d['cpu'], p))
            idx += 1

    stdscr.addstr(idx, 1, "\t\t\t\t%.2f" % cpusum)
    idx += 1
    c = stdscr.getch()
    # quit on q
    if c == ord('q'):
        break
    stdscr.erase()
    stdscr.refresh()

curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
===========================================
--
Web/Blog/Gallery: http://floatingsun.net/blog

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users