|
|
465c2f |
diff -up dstat-0.7.2/docs/dstat.1.bits dstat-0.7.2/docs/dstat.1
|
|
|
465c2f |
--- dstat-0.7.2/docs/dstat.1.bits 2010-06-15 00:26:19.000000000 +0200
|
|
|
465c2f |
+++ dstat-0.7.2/docs/dstat.1 2012-09-03 14:26:57.930801564 +0200
|
|
|
465c2f |
@@ -137,6 +137,9 @@ expand \-C, \-D, \-I, \-N and \-S discov
|
|
|
465c2f |
\-v, \-\-vmstat
|
|
|
465c2f |
equals \-pmgdsc \-D total
|
|
|
465c2f |
.TP
|
|
|
465c2f |
+\-\-bits
|
|
|
465c2f |
+force bits for values expressed in bytes
|
|
|
465c2f |
+.TP
|
|
|
465c2f |
\-\-float
|
|
|
465c2f |
force float values on screen (mutual exclusive with
|
|
|
465c2f |
\fB\-\-integer\fR)
|
|
|
465c2f |
diff -up dstat-0.7.2/dstat.bits dstat-0.7.2/dstat
|
|
|
465c2f |
--- dstat-0.7.2/dstat.bits 2010-06-11 08:08:01.000000000 +0200
|
|
|
465c2f |
+++ dstat-0.7.2/dstat 2012-09-03 14:23:42.056447576 +0200
|
|
|
465c2f |
@@ -72,6 +72,7 @@ pluginpath = [
|
|
|
465c2f |
class Options:
|
|
|
465c2f |
def __init__(self, args):
|
|
|
465c2f |
self.args = args
|
|
|
465c2f |
+ self.bits = False
|
|
|
465c2f |
self.blackonwhite = False
|
|
|
465c2f |
self.count = -1
|
|
|
465c2f |
self.cpulist = None
|
|
|
465c2f |
@@ -112,7 +113,7 @@ class Options:
|
|
|
465c2f |
|
|
|
465c2f |
try:
|
|
|
465c2f |
opts, args = getopt.getopt(args, 'acdfghilmno:prstTvyC:D:I:M:N:S:V',
|
|
|
465c2f |
- ['all', 'all-plugins', 'bw', 'blackonwhite', 'debug',
|
|
|
465c2f |
+ ['all', 'all-plugins', 'bits', 'bw', 'blackonwhite', 'debug',
|
|
|
465c2f |
'filesystem', 'float', 'full', 'help', 'integer',
|
|
|
465c2f |
'list', 'mods', 'modules', 'nocolor', 'noheaders', 'noupdate',
|
|
|
465c2f |
'output=', 'pidfile=', 'profile', 'version', 'vmstat'] + allplugins)
|
|
|
465c2f |
@@ -175,6 +176,8 @@ class Options:
|
|
|
465c2f |
plugins = {}.fromkeys(allplugins).keys()
|
|
|
465c2f |
plugins.sort()
|
|
|
465c2f |
self.plugins += plugins
|
|
|
465c2f |
+ elif opt in ['--bits']:
|
|
|
465c2f |
+ self.bits = True
|
|
|
465c2f |
elif opt in ['--bw', '--black-on-white']:
|
|
|
465c2f |
self.blackonwhite = True
|
|
|
465c2f |
elif opt in ['--debug']:
|
|
|
465c2f |
@@ -301,6 +304,7 @@ Dstat options:
|
|
|
465c2f |
-f, --full automatically expand -C, -D, -I, -N and -S lists
|
|
|
465c2f |
-v, --vmstat equals -pmgdsc -D total
|
|
|
465c2f |
|
|
|
465c2f |
+ --bits force bits for values expressed in bytes
|
|
|
465c2f |
--float force float values on screen
|
|
|
465c2f |
--integer force integer values on screen
|
|
|
465c2f |
|
|
|
465c2f |
@@ -428,10 +432,10 @@ class dstat:
|
|
|
465c2f |
ret = theme['title']
|
|
|
465c2f |
if isinstance(self.name, types.StringType):
|
|
|
465c2f |
width = self.statwidth()
|
|
|
465c2f |
- return ret + self.name[0:width].center(width).replace(' ', '-') + theme['default']
|
|
|
465c2f |
+ return ret + self.name[0:width].center(width, char['space']).replace(' ', '-') + theme['default']
|
|
|
465c2f |
for i, name in enumerate(self.name):
|
|
|
465c2f |
width = self.colwidth()
|
|
|
465c2f |
- ret = ret + name[0:width].center(width).replace(' ', '-')
|
|
|
465c2f |
+ ret = ret + name[0:width].center(width, char['space']).replace(' ', '-')
|
|
|
465c2f |
if i + 1 != len(self.name):
|
|
|
465c2f |
if op.color:
|
|
|
465c2f |
ret = ret + theme['frame'] + char['dash'] + theme['title']
|
|
|
465c2f |
@@ -443,13 +447,13 @@ class dstat:
|
|
|
465c2f |
ret = ''
|
|
|
465c2f |
if isinstance(self.name, types.StringType):
|
|
|
465c2f |
for i, nick in enumerate(self.nick):
|
|
|
465c2f |
- ret = ret + theme['subtitle'] + nick[0:self.width].center(self.width) + theme['default']
|
|
|
465c2f |
+ ret = ret + theme['subtitle'] + nick[0:self.width].center(self.width, char['space']) + theme['default']
|
|
|
465c2f |
if i + 1 != len(self.nick): ret = ret + char['space']
|
|
|
465c2f |
return ret
|
|
|
465c2f |
else:
|
|
|
465c2f |
for i, name in enumerate(self.name):
|
|
|
465c2f |
for j, nick in enumerate(self.nick):
|
|
|
465c2f |
- ret = ret + theme['subtitle'] + nick[0:self.width].center(self.width) + theme['default']
|
|
|
465c2f |
+ ret = ret + theme['subtitle'] + nick[0:self.width].center(self.width, char['space']) + theme['default']
|
|
|
465c2f |
if j + 1 != len(self.nick): ret = ret + char['space']
|
|
|
465c2f |
if i + 1 != len(self.name): ret = ret + theme['frame'] + char['colon']
|
|
|
465c2f |
return ret
|
|
|
465c2f |
@@ -679,7 +683,7 @@ class dstat_cpu24(dstat):
|
|
|
465c2f |
class dstat_disk(dstat):
|
|
|
465c2f |
def __init__(self):
|
|
|
465c2f |
self.nick = ('read', 'writ')
|
|
|
465c2f |
- self.type = 'd'
|
|
|
465c2f |
+ self.type = 'b'
|
|
|
465c2f |
self.diskfilter = re.compile('^(dm-\d+|md\d+|[hsv]d[a-z]+\d+)$')
|
|
|
465c2f |
self.open('/proc/diskstats')
|
|
|
465c2f |
self.cols = 2
|
|
|
465c2f |
@@ -745,7 +749,7 @@ class dstat_disk(dstat):
|
|
|
465c2f |
class dstat_disk24(dstat):
|
|
|
465c2f |
def __init__(self):
|
|
|
465c2f |
self.nick = ('read', 'writ')
|
|
|
465c2f |
- self.type = 'd'
|
|
|
465c2f |
+ self.type = 'b'
|
|
|
465c2f |
self.diskfilter = re.compile('(dm-\d+|md\d+|[hsv]d[a-z]+\d+)')
|
|
|
465c2f |
self.open('/proc/partitions')
|
|
|
465c2f |
if self.fd and not self.discover:
|
|
|
465c2f |
@@ -810,7 +814,7 @@ class dstat_disk24(dstat):
|
|
|
465c2f |
class dstat_disk24old(dstat):
|
|
|
465c2f |
def __init__(self):
|
|
|
465c2f |
self.nick = ('read', 'writ')
|
|
|
465c2f |
- self.type = 'd'
|
|
|
465c2f |
+ self.type = 'b'
|
|
|
465c2f |
self.diskfilter = re.compile('(dm-\d+|md\d+|[hsv]d[a-z]+\d+)')
|
|
|
465c2f |
self.regexp = re.compile('^\((\d+),(\d+)\):\(\d+,\d+,(\d+),\d+,(\d+)\)$')
|
|
|
465c2f |
self.open('/proc/stat')
|
|
|
465c2f |
@@ -1188,7 +1192,7 @@ class dstat_mem(dstat):
|
|
|
465c2f |
class dstat_net(dstat):
|
|
|
465c2f |
def __init__(self):
|
|
|
465c2f |
self.nick = ('recv', 'send')
|
|
|
465c2f |
- self.type = 'd'
|
|
|
465c2f |
+ self.type = 'b'
|
|
|
465c2f |
self.totalfilter = re.compile('^(lo|bond\d+|face|.+\.\d+)$')
|
|
|
465c2f |
self.open('/proc/net/dev')
|
|
|
465c2f |
self.cols = 2
|
|
|
465c2f |
@@ -1599,6 +1603,7 @@ char = {
|
|
|
465c2f |
'space': ' ',
|
|
|
465c2f |
'dash': '-',
|
|
|
465c2f |
'plus': '+',
|
|
|
465c2f |
+ 'underscore': '_',
|
|
|
465c2f |
}
|
|
|
465c2f |
|
|
|
465c2f |
def set_theme():
|
|
|
465c2f |
@@ -1863,7 +1868,7 @@ def cprintlist(varlist, type, width, sca
|
|
|
465c2f |
ret = sep = ''
|
|
|
465c2f |
for var in varlist:
|
|
|
465c2f |
ret = ret + sep + cprint(var, type, width, scale)
|
|
|
465c2f |
- sep = ' '
|
|
|
465c2f |
+ sep = char['space']
|
|
|
465c2f |
return ret
|
|
|
465c2f |
|
|
|
465c2f |
def cprint(var, type = 'f', width = 4, scale = 1000):
|
|
|
465c2f |
@@ -1882,14 +1887,18 @@ def cprint(var, type = 'f', width = 4, s
|
|
|
465c2f |
### If this is a negative value, return a dash
|
|
|
465c2f |
if var < 0:
|
|
|
465c2f |
if unit:
|
|
|
465c2f |
- return theme['error'] + '-'.rjust(width) + ' ' + theme['default']
|
|
|
465c2f |
+ return theme['error'] + '-'.rjust(width, char['space']) + char['space'] + theme['default']
|
|
|
465c2f |
else:
|
|
|
465c2f |
- return theme['error'] + '-'.rjust(width) + theme['default']
|
|
|
465c2f |
+ return theme['error'] + '-'.rjust(width, char['space']) + theme['default']
|
|
|
465c2f |
|
|
|
465c2f |
- if base == 1024:
|
|
|
465c2f |
- units = ('B', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
|
|
465c2f |
+ if base != 1024:
|
|
|
465c2f |
+ units = (char['space'], 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
|
|
465c2f |
+ elif op.bits and type in ('b', ):
|
|
|
465c2f |
+ units = ('b', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
|
|
465c2f |
+ base = scale = 1000
|
|
|
465c2f |
+ var = var * 8.0
|
|
|
465c2f |
else:
|
|
|
465c2f |
- units = (' ', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
|
|
465c2f |
+ units = ('B', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
|
|
|
465c2f |
|
|
|
465c2f |
if step == op.delay:
|
|
|
465c2f |
colors = theme['colors_lo']
|
|
|
465c2f |
@@ -1901,11 +1910,11 @@ def cprint(var, type = 'f', width = 4, s
|
|
|
465c2f |
cunit = theme['unit_hi']
|
|
|
465c2f |
|
|
|
465c2f |
### Convert value to string given base and field-length
|
|
|
465c2f |
- if op.integer and type in ('d', 'p', 'f'):
|
|
|
465c2f |
+ if op.integer and type in ('b', 'd', 'p', 'f'):
|
|
|
465c2f |
ret, c = dchg(var, width, base)
|
|
|
465c2f |
- elif op.float and type in ('d', 'p', 'f'):
|
|
|
465c2f |
+ elif op.float and type in ('b', 'd', 'p', 'f'):
|
|
|
465c2f |
ret, c = fchg(var, width, base)
|
|
|
465c2f |
- elif type in ('d', 'p'):
|
|
|
465c2f |
+ elif type in ('b', 'd', 'p'):
|
|
|
465c2f |
ret, c = dchg(var, width, base)
|
|
|
465c2f |
elif type in ('f'):
|
|
|
465c2f |
ret, c = fchg(var, width, base)
|
|
|
465c2f |
@@ -1925,23 +1934,23 @@ def cprint(var, type = 'f', width = 4, s
|
|
|
465c2f |
color = colors[int(var/scale)%len(colors)]
|
|
|
465c2f |
elif type in ('p'):
|
|
|
465c2f |
color = colors[int(round(var)/scale)%len(colors)]
|
|
|
465c2f |
- elif type in ('d', 'f'):
|
|
|
465c2f |
+ elif type in ('b', 'd', 'f'):
|
|
|
465c2f |
color = colors[c%len(colors)]
|
|
|
465c2f |
else:
|
|
|
465c2f |
color = ctext
|
|
|
465c2f |
|
|
|
465c2f |
### Justify value to left if string
|
|
|
465c2f |
if type in ('s',):
|
|
|
465c2f |
- ret = color + ret.ljust(width)
|
|
|
465c2f |
+ ret = color + ret.ljust(width, char['space'])
|
|
|
465c2f |
else:
|
|
|
465c2f |
- ret = color + ret.rjust(width)
|
|
|
465c2f |
+ ret = color + ret.rjust(width, char['space'])
|
|
|
465c2f |
|
|
|
465c2f |
### Add unit to output
|
|
|
465c2f |
if unit:
|
|
|
465c2f |
if c != -1 and round(var) != 0:
|
|
|
465c2f |
ret += cunit + units[c]
|
|
|
465c2f |
else:
|
|
|
465c2f |
- ret += ' '
|
|
|
465c2f |
+ ret += char['space']
|
|
|
465c2f |
|
|
|
465c2f |
return ret
|
|
|
465c2f |
|