Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed May 2, 2005
1 parent 7f8e484 commit b959e95
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tr:
next if (s|self\.intmap\[(\S+)\.strip\(\)\.lower\(\)\]|self.intmap[string.strip(string.lower($$1))]|g); \
next if (s|\((.0.) \+ (. .) \* len\((\S+)\)\)\.rjust\((\S+)\)|string.rjust($$1 + $$2 * len($$3), $$4)|g); \
next if (s|(\S+)\.replace\((.:.), (. .)\)\.split\(\)|string.split(string.replace($$1, $$2, $$3))|g); \
next if (s|ret\[name\.strip\(\)\.lower\(\)\]|name = string.lower(string.strip(name))\n ret[name]|g); \
s|(\S+)\.replace\((.+), (.+)\)|string.replace($$1, $$2, $$3)|g; \
s|(\S+)\.rjust\((.+)\)|string.rjust($$1, $$2)|g; \
s|(\S+)\.center\((.+)\)|string.center($$1, $$2)|g; \
Expand Down
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
+ Add --config option and use /etc/dstat.conf and ~/.dstat to influence output (see example dstat.conf)
+ Allow to force to given magnitude (--unit=kilo)
+ Look at possibilities to show deviation (on second line ?)
+ Check for dark/light background color and change colors accordingly (see dstat.conf)

### Export/Graph
+ Interface with rrdtool (python-rrd ?)
Expand Down
30 changes: 18 additions & 12 deletions dstat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ from __future__ import generators
try:
import sys, signal, os, re, time
import types, curses, signal, resource
sys.path.insert(0, '.')
sys.path.insert(0, './stats/')
sys.path.insert(0, '/usr/share/dstat/')
except KeyboardInterrupt, e:
pass
Expand All @@ -27,7 +29,7 @@ if sys.version_info < (2, 2):
sys.exit('error: Python 2.2 or later required, try dstat15 instead')

### Workaround for python < 2.3
if not callable(enumerate):
if not callable('enumerate'):
if sys.version_info < (2, 3) and sys.version_info >= (2, 2):
def enumerate(sequence):
index = 0
Expand All @@ -44,7 +46,7 @@ if not callable(enumerate):
return list

### Workaround for python < 2.3
if not callable(sum):
if not callable('sum'):
def sum(sequence):
ret = 0
for i in sequence:
Expand Down Expand Up @@ -551,7 +553,7 @@ class dstat_disk(dstat):
list = ('total', )
else:
list = self.discover()
if len(list) > 2: list = list[0:2]
# if len(list) > 2: list = list[0:2]
list.sort()
for name in list:
if name in self.discover('total') + op.diskset.keys():
Expand Down Expand Up @@ -615,7 +617,7 @@ class dstat_disk24(dstat):
list = ('total', )
else:
list = self.discover()
if len(list) > 2: list = list[0:2]
# if len(list) > 2: list = list[0:2]
list.sort()
for name in list:
if name in self.discover('total') + op.diskset.keys():
Expand Down Expand Up @@ -678,7 +680,7 @@ class dstat_disk24old(dstat):
list = ('total', )
else:
list = self.discover()
if len(list) > 2: list = list[0:2]
# if len(list) > 2: list = list[0:2]
list.sort()
for name in list:
if name in self.discover('total') + op.diskset.keys():
Expand Down Expand Up @@ -964,7 +966,7 @@ class dstat_net(dstat):
list = ('total', )
else:
list = self.discover()
if len(list) > 2: list = list[0:2]
# if len(list) > 2: list = list[0:2]
list.sort()
for name in list:
if name in self.discover('total', 'lo'):
Expand All @@ -980,9 +982,9 @@ class dstat_net(dstat):
if l[2] == '0' and l[10] == '0': continue
name = l[0]
if name in self.vars :
self.cn2[name] = ( long(l[2]), long(l[10]) )
self.cn2[name] = ( long(l[1]), long(l[9]) )
if name not in ('lo','face'):
self.cn2['total'] = ( self.cn2['total'][0] + long(l[2]), self.cn2['total'][1] + long(l[10]))
self.cn2['total'] = ( self.cn2['total'][0] + long(l[1]), self.cn2['total'][1] + long(l[9]))
if update:
for name in self.cn2.keys():
self.val[name] = (
Expand Down Expand Up @@ -1272,8 +1274,8 @@ def ticks():
def dopen(file):
global fds
if not os.path.exists(file): return None
if not 'fds' in globals(): fds = {}
if not file in fds:
if 'fds' not in globals(): fds = {}
if file not in fds:
fds[file] = open(file, 'r', 0)
else:
fds[file].seek(0)
Expand All @@ -1294,6 +1296,8 @@ def dchg(var, max, base):
break
var = var / base
c = c + 1
else:
c = -1
return ret, c

def fchg(var, max, base):
Expand All @@ -1313,6 +1317,8 @@ def fchg(var, max, base):
break
var = var / base
c = c + 1
else:
c = -1
return ret, c

def cprintlist(list, format):
Expand All @@ -1323,7 +1329,7 @@ def cprintlist(list, format):
return ret

def cprint(var, format = ('f', 4, 1000)):
c = 0
c = -1
type = format[0]
max = format[1]
mp = format[2]
Expand Down Expand Up @@ -1372,7 +1378,7 @@ def cprint(var, format = ('f', 4, 1000)):
ret = ansi[color] + ret.rjust(max)

if unit:
if c:
if c != -1 and var != 0:
ret = ret + units[c]
else:
ret = ret + ' '
Expand Down
2 changes: 2 additions & 0 deletions dstat.1
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ The default delay is 1 and count is unspecified (unlimited)
.SH INTERMEDIATE UPDATES
When invoking dstat with a \fBdelay\fR greater than 1 and without the \fB--noupdate\fR option, it will show intermediate updates, ie. the first time a 1 sec average, the second update a 2 second average, etc. until the delay has been reached.

\fBSo the 9 intermediate updates are NOT snapshots\fR, they are averages over the time that passed since the last final update. The end result is that you get a 10 second average on a new line, just like vmstat.

.SH BUGS
Since it's practically impossible to test dstat on every possible permutation of kernel , python or distribution version, I need your help and your feedback to fix the remaining problems. If you have improvements or bugreports, please send them to: dag@wieers.com

Expand Down
2 changes: 2 additions & 0 deletions dstat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ noheader = true
noupdate = true
default-options = -cdns
unit = k
background = light
update-method = interval-average # snapshot total-average

[colors]
default = red yellow green blue magenta cyan white darkred darkgreen
Expand Down
4 changes: 2 additions & 2 deletions dstat15
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ except KeyboardInterrupt, e:
# sys.exit('error: Python 1.5 or later required')

### Workaround for python < 2.3 (FIXME: check for sys.version_info existence)
if not callable(enumerate):
if not callable('enumerate'):
if sys.version_info < (2, 3) and sys.version_info >= (2, 2):
def enumerate(sequence):
index = 0
Expand All @@ -44,7 +44,7 @@ if not callable(enumerate):
return list

### Workaround for python < 2.3
if not callable(sum):
if not callable('sum'):
def sum(sequence):
ret = 0
for i in sequence:
Expand Down

0 comments on commit b959e95

Please sign in to comment.