Permalink
Browse files

More small updates

  • Loading branch information...
1 parent f36b27e commit 963f810893f4e40686909be7727c78554f86d02b @dagwieers committed May 26, 2006
Showing with 30 additions and 27 deletions.
  1. +2 −0 ChangeLog
  2. +7 −7 dstat
  3. +21 −20 plugins/dstat_app.py
View
@@ -5,6 +5,8 @@
- Fixed sum() and enumerate() only when it isn't there (Jesse Young)
- Added external plugins dstat_app
- Added ibm-acpi support to dstat_thermal
+- Exclude md-devices from total
+- Improved debug output somewhat
* 0.6.2 - Cumbernauld - released 08/03/2006
- Fixed situation where no TERM environment variable was set (William Webber)
View
14 dstat
@@ -205,7 +205,7 @@ class Options:
print
rows, cols = getwinsize()
print 'Terminal type:', os.getenv('TERM') + '/' + termtype
- print 'Terminal: %d lines, %d columns' % (rows, cols)
+ print 'Terminal size: %d lines, %d columns' % (rows, cols)
print
print 'Processors: %d' % getcpunr()
print 'Pagesize: %d' % resource.getpagesize()
@@ -588,7 +588,7 @@ class dstat_disk(dstat):
if l[5] == '0' and l[9] == '0': continue
name = l[2]
if l[3:] == ['0',] * 11: continue
- if not re.match('(md[0-9]+)', name):
+ if not re.match('(md[0-9]+|dm-[0-9]+)', name):
self.cn2['total'] = ( self.cn2['total'][0] + long(l[5]), self.cn2['total'][1] + long(l[9]) )
if name in self.vars and name != 'total':
self.cn2[name] = ( self.cn2[name][0] + long(l[5]), self.cn2[name][1] + long(l[9]) )
@@ -649,7 +649,7 @@ class dstat_disk24(dstat):
l = line.split()
if len(l) < 15 or l[0] == 'major' or int(l[1]) % 16 != 0: continue
name = l[3]
- if not re.match('(md[0-9]+)', name):
+ if not re.match('(md[0-9]+|dm-[0-9]+)', name):
self.cn2['total'] = ( self.cn2['total'][0] + long(l[6]), self.cn2['total'][1] + long(l[10]) )
if name in self.vars:
self.cn2[name] = ( self.cn2[name][0] + long(l[6]), self.cn2[name][1] + long(l[10]) )
@@ -1763,11 +1763,11 @@ def main():
### Print debugging output
if op.debug: t2 = time.time(); tt = tt + (t2 - t1) * 1000
- if op.debug:
+ if op.debug == 1:
if loop == 0: tt = tt * step
- sys.stdout.write(' %6.3f' % (tt / step))
+ sys.stdout.write('%6.2fms' % (tt / step))
if op.debug > 1:
- sys.stdout.write(' [%d:%d:%d] ' % (loop, update, step))
+ sys.stdout.write('%6.2f [%d:%d:%d]' % (tt/step, loop, update, step))
### If intermediate results, update increases with 1 sec (=interval)
update = update + interval
@@ -1784,7 +1784,7 @@ def main():
if step == op.delay:
sys.stdout.write('\n' + ansi['reset'] + ansi['clearline'] + ansi['save'])
else:
- sys.stdout.write(ansi['clearline'] + ansi['restore'])
+ sys.stdout.write(ansi['restore'])
loop = (update + op.delay - 1) / op.delay
step = ((update - 1) % op.delay) + 1
View
@@ -3,8 +3,6 @@
###
### Authority: dag@wieers.com
-### FIXME: The val, cn1 and cn2 will only grow and consume more memory.
-
global string
import string
@@ -25,30 +23,33 @@ def extract(self):
if not self.cn1.has_key(pid):
self.cn1[pid] = 0
- for line in dopen('/proc/%s/stat' % pid).readlines():
- l = string.split(line)
- if len(l) < 15: continue
- self.cn2[pid] = int(l[13]) + int(l[14])
- self.val[pid] = (self.cn2[pid] - self.cn1[pid]) * 1.0 / tick
+ l = string.split(dopen('/proc/%s/stat' % pid).read())
+ if len(l) < 15: continue
+ self.cn2[pid] = int(l[13]) + int(l[14])
+ usage = (self.cn2[pid] - self.cn1[pid]) * 1.0 / tick
### Get the process that spends the most jiffies
- if self.val[pid] > max:
- max = self.val[pid]
+ if usage > max:
+ max = usage
self.val['process'] = l[1][1:-1]
- ### Debug
-# self.val['process'] = self.val['process'] + ' ' + str(max)
-# self.val['process'] = self.val['process'] + ' ' + l[13] + ':' + l[14]
+ ### If the name is a known interpreter, take the second argument from the cmdline
+ if self.val['process'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
+ for line in dopen('/proc/%s/cmdline' % pid).readlines():
+ self.val['process'] = os.path.basename(string.split(line, '\0')[1])
+
+ ### Debug (show PID)
+# self.val['process'] = '%s %s' % (pid, self.val['process'])
+
+ ### Debug (show CPU usage)
+# self.val['process'] = '%s %d' % (self.val['process'], usage)
+
+ ### Debug (show CPU kernel/user values)
+# self.val['process'] = '%s %d:%d' % (self.val['process'], int(l[13]) / tick, int(l[14]) / tick)
### Garbage collect sort off
-# if self.val[pid] == 0:
-# del(self.cn1[pid]); del(self.cn2[pid]); del(self.val[pid])
-
- ### If the name is a known interpreter, take the second argument from the cmdline
- if self.val['process'] in ('perl', 'python', 'sh', 'bash'):
- for line in dopen('/proc/%s/cmdline' % pid).readlines():
- l = string.split(line, '\0')
- self.val['process'] = os.path.basename(l[1])
+# if value == 0:
+# del(self.cn1[pid]); del(self.cn2[pid])
if step == op.delay:
self.cn1.update(self.cn2)

0 comments on commit 963f810

Please sign in to comment.