8 self
.base
= '/sys/kernel/debug/kvm'
10 for key
in os
.listdir(self
.base
):
11 self
.values
[key
] = None
13 for key
, oldval
in self
.values
.iteritems():
14 newval
= int(file(self
.base
+ '/' + key
).read())
16 if oldval
is not None:
17 newdelta
= newval
- oldval
[0]
18 self
.values
[key
] = (newval
, newdelta
)
21 if not os
.access('/sys/kernel/debug', os
.F_OK
):
22 print 'Please enable CONFIG_DEBUG_FS in your kernel'
24 if not os
.access('/sys/kernel/debug/kvm', os
.F_OK
):
25 print "Please mount debugfs ('mount -t debugfs debugfs /sys/kernel/debug')"
26 print "and ensure the kvm modules are loaded"
34 def main(screen
, stats
):
35 curses
.use_default_colors()
39 screen
.addstr(0, 0, 'kvm statistics')
42 for key
in sorted(s
.keys()):
45 screen
.addstr(row
, col
, key
)
47 screen
.addstr(row
, col
, '%10d' % (values
[0],))
49 if values
[1] is not None:
50 screen
.addstr(row
, col
, '%8d' % (values
[1],))
61 except KeyboardInterrupt:
68 curses
.wrapper(main
, stats
)