diff options
author | Avi Kivity <avi@qumranet.com> | 2006-09-13 08:23:04 +0000 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2006-09-13 08:23:04 +0000 |
commit | 306a298e5f9d90cf234c5eb081c3ff224d431e96 (patch) | |
tree | bfb80ea66aa30a031f6df78a105af096a0cb408e /kvm/kvm_stat | |
parent | kvm: fix dirty page logging (diff) | |
download | qemu-kvm-306a298e5f9d90cf234c5eb081c3ff224d431e96.tar.gz qemu-kvm-306a298e5f9d90cf234c5eb081c3ff224d431e96.tar.bz2 qemu-kvm-306a298e5f9d90cf234c5eb081c3ff224d431e96.zip |
kvm: add top-like utility for displaying kvm statistics
Diffstat (limited to 'kvm/kvm_stat')
-rwxr-xr-x | kvm/kvm_stat | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kvm/kvm_stat b/kvm/kvm_stat new file mode 100755 index 000000000..af13dea2a --- /dev/null +++ b/kvm/kvm_stat @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import curses +import os, time + +#for i in /sys/kernel/debug/kvm/*; do echo $(basename $i) $(cat $i); done + +class Stats: + def __init__(self): + self.base = '/sys/kernel/debug/kvm' + self.values = {} + for key in os.listdir(self.base): + self.values[key] = None + def get(self): + for key, oldval in self.values.iteritems(): + newval = int(file(self.base + '/' + key).read()) + newdelta = None + if oldval is not None: + newdelta = newval - oldval[0] + self.values[key] = (newval, newdelta) + return self.values + +stats = Stats() + +def main(screen, stats): + curses.noecho() + def refresh(): + screen.erase() + screen.addstr(0, 0, 'kvm statistics') + row = 2 + s = stats.get() + for key in sorted(s.keys()): + values = s[key] + screen.addstr(row, 1, key) + screen.addstr(row, 12, '%10d' % (values[0],)) + if values[1]: + screen.addstr(row, 22, '%8d' % (values[1],)) + row += 1 + screen.refresh() + + while True: + refresh() + curses.halfdelay(10) + try: + c = screen.getkey() + if c == 'q': + break + except KeyboardInterrupt: + break + except curses.error: + continue + + +import curses.wrapper +curses.wrapper(main, stats) + |