Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Added internal dstat_vm plugin showing page faults, allocations and f…
Browse files Browse the repository at this point in the history
…rees
  • Loading branch information
dagwieers committed Dec 2, 2008
1 parent b4f5d8e commit 60d8968
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 28 additions & 5 deletions dstat
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 60d8968

Please sign in to comment.