Blame SOURCES/dstat-0.7.2-bits.patch

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