Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update

  • Loading branch information...
commit 8b304f740ab22d1aaece376a9a9a3f47271a6628 1 parent c2e4b7f
@dagwieers authored
Showing with 33 additions and 26 deletions.
  1. +1 −0  ChangeLog
  2. +1 −1  TODO
  3. +30 −24 dstat
  4. +1 −1  dstat.1
View
1  ChangeLog
@@ -5,6 +5,7 @@
- Change terminal title (if terminal supports it)
- Don't trim the cpulist to 2 items when -f (S�bastien Prud'homme)
- Exclude md-devices from total (Peter Cordes)
+- Now accept 'total' keyword with -C (like -D and -N)
* 0.6.0 - Bettiesbaai - released 29/05/2005
- Removed keyboard input prevention patch. (Dbt 304673, Marc Lehmann)
View
2  TODO
@@ -35,7 +35,7 @@
+ Python 1.5 prints 'L' for long, crashes when int()
+ Implement better (?) protection against counter rollovers
+ Plugins currently have to be written in python 1.5 to work for dstat15 (lowest common denominator)
-+ One of the plugins (or the main implementation) has a memory leak after days of running 200MB of memory is not uncommon
++ One of the plugins (or the main implementation) has a memory leak after days of running 200MB of memory is not uncommon (python 2.2.3 memory leak ?)
### Plugin issues
+ tcp plugin is very slow and generates lots of softirqs (on busy systems), to be confirmed
View
54 dstat
@@ -217,7 +217,7 @@ class Options:
Dstat options:
-c, --cpu enable cpu stats
- -C 0,3, include cpu0, cpu3 and total
+ -C 0,3,total include cpu0, cpu3 and total
-d, --disk enable disk stats
-D total,hda include hda and total
-g, --page enable page stats
@@ -419,13 +419,17 @@ class dstat_cpu(dstat):
self.open('/proc/stat')
self.nick = ( 'usr', 'sys', 'idl', 'wai', 'hiq', 'siq' )
self.vars = self.vars()
- self.name = []
+ self.name = self.name()
+ self.init(self.vars + ['total',], 6)
+
+ def name(self):
+ ret = []
for name in self.vars:
- if name:
- self.name.append('cpu' + name + ' usage')
+ if name == 'total':
+ ret.append('total cpu usage')
else:
- self.name.append('total cpu usage')
- self.init(self.vars + ['',], 6)
+ ret.append('cpu' + name + ' usage')
+ return ret
def discover(self, *list):
ret = []
@@ -444,7 +448,7 @@ class dstat_cpu(dstat):
if op.cpulist:
list = op.cpulist
elif not op.full:
- list = ('', )
+ list = ('total', )
else:
list = []
cpu = 0
@@ -453,7 +457,7 @@ class dstat_cpu(dstat):
cpu = cpu + 1
# if len(list) > 2: list = list[0:2]
for name in list:
- if name in self.discover(''):
+ if name in self.discover('total'):
ret.append(name)
return ret
@@ -463,8 +467,8 @@ class dstat_cpu(dstat):
l = line.split()
if len(l) < 8: continue
for name in self.vars:
- if l[0] != 'cpu' + name: continue
- self.cn2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]), long(l[5]), long(l[6]), long(l[7]) )
+ if l[0] == 'cpu' + name or ( l[0] == 'cpu' and name == 'total' ):
+ self.cn2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]), long(l[5]), long(l[6]), long(l[7]) )
for name in self.vars:
for i in range(6):
self.val[name][i] = 100.0 * (self.cn2[name][i] - self.cn1[name][i]) / (sum(self.cn2[name]) - sum(self.cn1[name]))
@@ -478,7 +482,7 @@ class dstat_cpu24(dstat):
self.nick = ( 'usr', 'sys', 'idl')
self.vars = self.vars()
self.name = self.name()
- self.init(self.vars + ['',], 3)
+ self.init(self.vars + ['total',], 3)
def name(self):
ret = []
@@ -505,7 +509,7 @@ class dstat_cpu24(dstat):
if op.cpulist:
list = op.cpulist
elif not op.full:
- list = ('', )
+ list = ('total', )
else:
list = []
cpu = 0
@@ -514,7 +518,7 @@ class dstat_cpu24(dstat):
cpu = cpu + 1
# if len(list) > 2: list = list[0:2]
for name in list:
- if name in self.discover(''):
+ if name in self.discover('total'):
ret.append(name)
return ret
@@ -523,8 +527,8 @@ class dstat_cpu24(dstat):
for line in self.fd.readlines():
l = line.split()
for name in self.vars:
- if len(l) < 5 or l[0] != 'cpu' + name: continue
- self.cn2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]) )
+ if l[0] == 'cpu' + name or ( l[0] == 'cpu' and name == 'total' ):
+ self.cn2[name] = ( long(l[1]) + long(l[2]), long(l[3]), long(l[4]) )
for name in self.vars:
for i in range(3):
self.val[name][i] = 100.0 * (self.cn2[name][i] - self.cn1[name][i]) / (sum(self.cn2[name]) - sum(self.cn1[name]))
@@ -1577,9 +1581,20 @@ def main():
user = getpass.getuser()
hostname = os.uname()[1].split('.')[0]
+
+ ### Write term-title
if re.compile('(screen|xterm*)').match(os.getenv('TERM')):
sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, os.path.basename(sys.argv[0]), ' '.join(op.args)))
+ ### Check terminal capabilities
+ if sys.stdout.isatty():
+ if 'curses' in sys.modules.keys() and hasattr(curses, 'tigetnum') and curses.tigetnum('colors') < 0:
+ op.color = False
+ else:
+ op.color = False
+ op.nolimit = True
+ op.update = False
+
if op.output:
if os.path.exists(op.output):
outputfile = open(op.output, 'a', 0)
@@ -1592,15 +1607,6 @@ def main():
outputfile.write('"Host:","%s",,,,"User:","%s"\n' % (hostname, user))
outputfile.write('"Cmdline:","dstat %s",,,,"Date:","%s"\n\n' % (' '.join(op.args), time.strftime('%d %b %Y %H:%M:%S %Z', time.localtime())))
- ### Check terminal capabilities
- if sys.stdout.isatty():
- if 'curses' in sys.modules.keys() and hasattr(curses, 'tigetnum') and curses.tigetnum('colors') < 0:
- op.color = False
- else:
- op.color = False
- op.nolimit = True
- op.update = False
-
rows, cols = getwinsize()
### Empty ansi database if no colors are requested
View
2  dstat.1
@@ -25,7 +25,7 @@ Users of Sleuthkit might find Sleuthkit's dstat being renamed to datastat to avo
\fB\-c\fR, \fB\-\-cpu\fR
enable cpu stats
.TP
-\fB\-C\fR 0,3,
+\fB\-C\fR 0,3,total
include cpu0, cpu3 and total
.TP
\fB\-d\fR, \fB\-\-disk\fR
Please sign in to comment.
Something went wrong with that request. Please try again.