[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-users] Measuring overall CPU utlization
> <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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |