Permalink
Browse files

Added internal dstat_vm plugin showing page faults, allocations and f…

…rees
  • Loading branch information...
1 parent b4f5d8e commit 60d8968cfe6b4f61f5c0b2be14d361546f2362d4 @dagwieers committed Dec 2, 2008
Showing with 29 additions and 5 deletions.
  1. +1 −0 ChangeLog
  2. +28 −5 dstat
View
@@ -7,6 +7,7 @@
- Added internal dstat_socket plugin to show total number of various sockets
- Added internal dstat_aio plugin to see number of asynchronous I/O requests
- Listing modules (-M list) now also lists internal plugins
+- Added internal dstat_vm plugin showing page faults, allocations and frees
* 0.6.8 - Buenos Aires - release 12/09/2008
- Added improved tick patch (Kelly Long)
View
33 dstat
@@ -107,7 +107,7 @@ class Options:
opts, args = getopt.getopt (args, 'acdfghilmno:pstTvyC:D:I:M:N:S:V',
['aio', 'cpu', 'disk', 'epoch', 'fs', 'filesystem', 'int', 'ipc',
'load', 'lock', 'mem', 'net', 'page', 'proc', 'raw', 'socket',
- 'swap', 'sys', 'tcp', 'time', 'udp', 'unix',
+ 'swap', 'sys', 'tcp', 'time', 'udp', 'unix', 'vm',
'all', 'debug', 'full', 'help', 'integer', 'list', 'mods', 'modules',
'nocolor', 'noheaders', 'noupdate', 'output=', 'pidfile=', 'version',
'vmstat'])
@@ -172,13 +172,15 @@ class Options:
self.modlist.append('udp')
elif opt in ['--unix']:
self.modlist.append('unix')
+ elif opt in ['--vm']:
+ self.modlist.append('vm')
elif opt in ['-y', '--sys']:
self.modlist.append('sys')
elif opt in ['-a', '--all']:
- self.modlist = self.modlist + ( 'cpu', 'disk', 'net', 'page', 'sys' )
+ self.modlist = self.modlist + [ 'cpu', 'disk', 'net', 'page', 'sys' ]
elif opt in ['-v', '--vmstat']:
- self.modlist = self.modlist + ( 'proc', 'mem', 'page', 'disk', 'sys', 'cpu' )
+ self.modlist = self.modlist + [ 'proc', 'mem', 'page', 'disk', 'sys', 'cpu' ]
elif opt in ['-f', '--full']:
self.full = True
@@ -280,6 +282,7 @@ Dstat options:
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
+ --vm enable vm stats
-M stat1,stat2 enable external plugins
--mods stat1,stat2
@@ -850,8 +853,8 @@ class dstat_fs(dstat):
def __init__(self):
self.name = 'filesystem'
self.format = ('d', 6, 1000)
- self.nick = ('#file', '#inode')
- self.vars = ('files', 'inodes')
+ self.nick = ('files', 'inodes')
+ self.vars = self.nick
self.init(self.vars, 1)
def extract(self):
@@ -1428,6 +1431,26 @@ class dstat_unix(dstat):
elif l[5] == '03':
self.val['established'] = self.val['established'] + 1
+class dstat_vm(dstat):
+ def __init__(self):
+ self.name = 'virtual memory'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/vmstat')
+ self.nick = ('fault', 'alloc', 'free')
+ self.vars = ('pgfault', 'pgalloc_normal', 'pgfree')
+ self.init(self.vars, 1)
+
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if len(l) < 2: continue
+ if l[0] not in self.vars: continue
+ self.cn2[l[0]] = long(l[1])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
+
### END STATS DEFINITIONS ###
ansi = {

0 comments on commit 60d8968

Please sign in to comment.