Permalink
Browse files

conv() update and proc stat changes

  • Loading branch information...
1 parent 11dd961 commit 8b9243983b17ac3301c71d73954e00eb1a9ed5ea @dagwieers committed Dec 14, 2004
Showing with 26 additions and 32 deletions.
  1. +2 −0 ChangeLog
  2. +5 −9 TODO
  3. +19 −23 dstat
View
@@ -14,6 +14,8 @@
- proc stats now show averages
- Check if output is a tty, else disable colors and updates
- Fixed bug in interrupt stats on smp systems
+- Improvement in output, 10.0k or 5.0 will be displayed simply as 10k or 5
+- proc stats now show floats
* 0.5.5
- In fact, round() was not the problem, use str() instead. (Anton Blanchard)
View
14 TODO
@@ -3,8 +3,9 @@
+ Allow to force to given magnitude
+ Look at possibilities to show deviation (on second line ?)
+ Improve manpage
-+ I should be able to detect when terminal has no ANSI capabilities (anyone?)
-+ Implement -I eth0,eth1 again
++ Detect terminal capabilities (colors, ANSI) using curses (?)
++ Find a way to use curses without the flickering and tty clearing in screen
++ Re-implement -I eth0,eth1
### Export/Graph
+ Add -o/--output option to save directly to a file
@@ -14,20 +15,15 @@
### Extending statistics (help welcome!)
+ Add all stats to seperate modules and allow people to plugin their own modules
+ Add application stats (-a or -A pid,cmd)
-+ Add icmp stats ?
-+ Add ntp stats
-+ Add nfs stats
++ Add icmp, nfs, ntp stats ?
+ Add user stats (number of users logged on)
+ Look into interfacing with apps (bind, sendmail, postfix, squid, amavisd, laus, samba)
+ Look into interfacing with specific HW counters in /proc
### General bugs
-+ If you have 2 devices with the same name, -I will only work on the first one
-+ When using -D foo, -I 99, -N eth9 dstat should fail when it does not exist
+ Timer is not accurate on 2.6 kernel, every second there's a 1ms deviation (every 17mins -> 1sec)
-+ Find a way to use curses without the flickering and clearing tty in screen
### Stat bugs
-+ tcp stat is very slow and generates lots of siq (on some systems)
++ tcp stat is very slow and generates lots of softirqs (on some systems)
+ proc stat seems to be off by one, no clue why
+ Implement better (?) protection against counter rollovers
View
42 dstat
@@ -274,10 +274,10 @@ class dstat:
sys.stdout.write('%s' % conv(self.len, self.val[name], 1000))
elif self.format == '%ps':
sys.stdout.write('%s' % conv(self.len, self.val[name], 100))
+ elif self.format == '%is':
+ sys.stdout.write('%s' % conv(self.len, self.val[name], 10))
elif self.format == '%f':
sys.stdout.write('%s' % conv(self.len, self.val[name], 1))
- elif self.format == '%is':
- sys.stdout.write('%s' % conv(self.len, self.val[name], 0))
elif self.format in ('%s %s', '%s:%s', '%s-%s'):
sys.stdout.write(self.format % convlist(self.len, self.val[name]))
sep = ansi['default'] + ':'
@@ -796,13 +796,14 @@ class dstat_proc(dstat):
if name == 'processes':
self.val['processes'] = 0
self.cn2[name] = long(l[1])
- elif name in ('procs_running', 'procs_blocked'):
+ elif name == 'procs_running':
+ self.cn2[name] = self.cn2[name] + long(l[1]) - 1
+ elif name == 'procs_blocked':
self.cn2[name] = self.cn2[name] + long(l[1])
- self.cn2['procs_running'] = self.cn2['procs_running'] - 1
if update:
- self.val['processes'] = (self.cn2['processes'] - self.cn1['processes']) / step
+ self.val['processes'] = (self.cn2['processes'] - self.cn1['processes']) * 1.0 / step
for name in ('procs_running', 'procs_blocked'):
- self.val[name] = self.cn2[name] / step
+ self.val[name] = self.cn2[name] * 1.0 / step
if step == op.delay:
self.cn1.update(self.cn2)
for name in ('procs_running', 'procs_blocked'):
@@ -979,6 +980,7 @@ def convlist(max, list, base = 1024):
#def convlist(max, list):
# return map(conv, list)
+### Use capabilities like: float=true, base=nr, color=true
def conv(max, var, base = 1024):
if var < 0:
return ansi['default'] + '- '.rjust(max)
@@ -988,45 +990,39 @@ def conv(max, var, base = 1024):
else:
color = ('darkred', 'darkyellow', 'darkgreen', 'darkblue', 'darkmagenta', 'darkcyan', 'silver', 'red', 'green')
- if base == 0:
- if round(var) == 0:
- return ansi['default'] + '0'.rjust(max)
- else:
- return ansi[color[long(round(var)/1000)]] + str(long(round(var))).rjust(max)
+ if base in (0, 1, 10):
+ unit = ('', '', '', '', '', '', '', '', '', '', '')
elif base == 100:
if round(var) == 0:
return ansi['default'] + '0'.rjust(max)
else:
return ansi[color[long(round(var)/34)]] + str(long(round(var))).rjust(max)
- elif base == 1:
- unit = ('', '', '')
elif base == 1000:
unit = (' ', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
- else:
+ elif base == 1024:
### lowercase (b) is better for the eyes than uppercase
unit = ('B', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
+ else:
+ return ansi['default'] + '? '.rjust(max)
c = 0
while True:
repr = str(long(round(var))) + unit[c]
if len(repr) <= max:
- if not op.integer and ( base != 1000 or c > 0):
- if len('%1.2f' % var + unit[c]) <= max:
+ if not op.integer and (base != 1000 or c > 0):
+ if var != round(var) and len('%1.2f' % var + unit[c]) <= max:
repr = '%1.2f' % var + unit[c]
- elif len('%1.1f' % var + unit[c]) <= max:
+ elif var != round(var) and len('%1.1f' % var + unit[c]) <= max:
repr = '%1.1f' % var + unit[c]
else:
var = long(round(var))
break
var = var / base
c = c + 1
- if type(var) == int and long(round(var)) != 0:
- return ansi[color[c]] + repr.rjust(max)
- elif var != 0:
- return ansi[color[c]] + repr.rjust(max)
- else:
- return ansi['default'] + '0 '.rjust(max)
+ if var == 0:
+ return ansi['default'] + ('0' + ' ' * len(unit[0])).rjust(max)
+ return ansi[color[c]] + repr.rjust(max)
def info(level, str):
"Output info message"

0 comments on commit 8b92439

Please sign in to comment.