diff options
author | Avi Kivity <avi@qumranet.com> | 2007-11-18 14:09:45 +0200 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-11-18 14:09:45 +0200 |
commit | 3617ce2063e67d5a24979bb9cc6a3830187a3bff (patch) | |
tree | 01a227cf0c3b87e645b48feefc71473368d73303 | |
parent | 27f9086756540fab9acb718706ef3fb681496532 (diff) |
kvm: stats: batch modekvm-53rc2
Signed-off-by: Avi Kivity <avi@qumranet.com>
-rwxr-xr-x | kvm/kvm_stat | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/kvm/kvm_stat b/kvm/kvm_stat index 5b27a75cb..92179398a 100755 --- a/kvm/kvm_stat +++ b/kvm/kvm_stat @@ -1,7 +1,7 @@ #!/usr/bin/python import curses -import sys, os, time +import sys, os, time, optparse class Stats: def __init__(self): @@ -31,7 +31,7 @@ stats = Stats() label_width = 20 number_width = 10 -def main(screen, stats): +def tui(screen, stats): curses.use_default_colors() curses.noecho() def refresh(): @@ -62,8 +62,26 @@ def main(screen, stats): break except curses.error: continue - -import curses.wrapper -curses.wrapper(main, stats) +def batch(stats): + s = stats.get() + time.sleep(1) + s = stats.get() + for key in sorted(s.keys()): + values = s[key] + print '%-22s%10d%10d' % (key, values[0], values[1]) +options = optparse.OptionParser() +options.add_option('-1', '--once', '--batch', + action = 'store_true', + default = False, + dest = 'once', + help = 'run in batch mode for one second', + ) +(options, args) = options.parse_args(sys.argv) + +if not options.once: + import curses.wrapper + curses.wrapper(tui, stats) +else: + batch(stats) |