2 # -*- coding: utf-8 -*-
4 # This file is part of Karesansui.
6 # Copyright (C) 2009-2010 HDE, Inc.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
21 from karesansui.lib.virt.virt import KaresansuiVirtConnection
24 stdscr = curses.initscr()
30 #curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
32 # timeout getch after 1s
35 (maxy, maxx) = stdscr.getmaxyx()
37 vtop_start = time.time()
40 conn = KaresansuiVirtConnection()
43 guests = conn.search_guests()
52 shares[name] = info[4]
55 stdscr.addstr(idx, 1, "Domain\t\tID\tVCPU\t%CPU\t%CPUSUM ", curses.A_REVERSE)
63 share = info[4] - shares[name]
64 p = (share*100)/((now - vtop_start) * 10**9)
66 stdscr.addstr(idx, 1, "%s\t%d\t%d\t%.2f\t%.2f" % (name, id, info[3], p, cpusum))
69 stdscr.addstr(idx, 1, "Press 'q' for quit.")