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"
31 def main(screen
, stats
):
32 curses
.use_default_colors()
36 screen
.addstr(0, 0, 'kvm statistics')
39 for key
in sorted(s
.keys()):
41 screen
.addstr(row
, 1, key
)
42 screen
.addstr(row
, 12, '%10d' % (values
[0],))
43 if values
[1] is not None:
44 screen
.addstr(row
, 22, '%8d' % (values
[1],))
55 except KeyboardInterrupt:
62 curses
.wrapper(main
, stats
)