Browse files

A serious bug.

  • Loading branch information...
1 parent 990f2f2 commit ec5e8a2bd17c9658b5bfe5d19cf3663c744570fd @dagwieers committed Nov 11, 2004
Showing with 49 additions and 22 deletions.
  1. +9 −5 ChangeLog
  2. +6 −2 TODO
  3. +31 −12 dstat
  4. +3 −3 dstat.spec
View
14 ChangeLog
@@ -1,3 +1,7 @@
+* 0.5.1
+- Fixed bug that caused counters to not be averages when delay > 1
+- Added time stats (-t)
+
* 0.5
- Changed some more int()'s into long()'s (Pasi Pirhonen)
- Fixed the cpu out of index, /proc instability (Pasi Pirhonen)
@@ -11,7 +15,7 @@
- Fixed 2 crash bugs caused by /proc instability
* 0.4
-- Added interrupt stats
+- Added interrupt stats (-i)
- Order of the stats adhere the order of the options
- Interval more precise, using signals instead of sleep
- Modular rewrite using classes
@@ -32,12 +36,12 @@
- Initial public release
* 0.3
-- Added load stats
-- Added memory stats
+- Added load stats (-l)
+- Added memory stats (-m)
- Output now fits into space and adds unit
- Converted all values to bytes
* 0.2
-- Added disk io
-- Added proc stats
+- Added disk io (-d)
+- Added proc stats (-p)
- Important layout changes
View
8 TODO
@@ -1,19 +1,23 @@
### Usability
+ Add --config option and use /etc/dstat.conf to influence output
-+ Add -o/--output option and parsable output options
++ Add -o/--output option to save directly to a file
++ Add --parse option to give parsable output (maybe CSV output ?)
+ Allow to force to given magnitude
+ Look at possibilities to show deviation (on second line ?)
### Extensions
+ Add all stats to seperate modules and allow people to plugin their own modules
### Statistics
++ Add time counter
+ Add application stats (-a or -A pid,cmd)
+ Add ip stats (icmp, tcp, udp)
+ Add ntp stats
+ Add user stats (number of users logged on)
-+ Look into interfacing with bind, sendmail, postfix, squid, amavisd, laus, gpfs, hw ?
++ Look into interfacing with apps (bind, sendmail, postfix, squid, amavisd, laus)
++ Look into interfacing with specific HW counters in /proc
### Bugs
+ Implement better (?) protection against counter rollovers
+ If you have 2 devices with the same name, -I will only work on the first one
++ When using -D hdk, -I 99, -N eth9 dstat should fail when it does not exist
View
43 dstat
@@ -14,11 +14,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Copyright 2004 Dag Wieers <dag@wieers.com>
-from __future__ import generators
-import os, sys, re, getopt, fcntl, termios, struct
+#from __future__ import generators
+import os, sys, re, getopt, fcntl, termios, struct, time
import ConfigParser, urlparse, signal, resource
-VERSION = "0.5"
+VERSION = "0.5.1"
enable = ('yes', 'on', 'true', '1')
disable = ('no', 'off', 'false', '0')
@@ -36,9 +36,9 @@ class Options:
self.header = True
try:
- opts, args = getopt.getopt (args, 'acdghilmnpsvyD:I:N:',
+ opts, args = getopt.getopt (args, 'acdghilmnpstvyD:I:N:',
['all', 'cpu', 'disk', 'help', 'int', 'load', 'mem', 'net',
- 'page', 'proc', 'swap', 'sys', 'version', 'vm', 'vmstat',
+ 'page', 'proc', 'swap', 'sys', 'time', 'version', 'vm', 'vmstat',
'integer', 'nocolor', 'noheader', 'noupdate'])
except getopt.error, exc:
print 'dstat: %s, try dstat -h for a list of all the options' % str(exc)
@@ -77,6 +77,8 @@ class Options:
self.modlist.append('proc')
elif opt in ['-s', '--swap']:
self.modlist.append('swap')
+ elif opt in ['-t', '--time']:
+ self.modlist.append('time')
elif opt in ['-y', '--sys']:
self.modlist.append('sys')
elif opt in ['-v', '--version']:
@@ -131,12 +133,13 @@ Dstat options:
-N eth1,total include eth1 and total
-p, --proc enable process stats
-s, --swap enable swap stats
+ -t, --time enable time counter
-y, --sys enable system stats
--integer show integer values
--nocolor disable colors
--noheader disable repetitive headers
- --noupdate disable intermediates updates when delay > 1
+ --noupdate disable intermediate updates when delay > 1
'''
class Config:
@@ -209,7 +212,7 @@ class dstat:
sys.stdout.write(self.format % conv(self.len, self.val[name]))
elif self.format in ('%s %s', '%s:%s', '%s-%s'):
sys.stdout.write(self.format % convlist(self.len, self.val[name]))
-# sep = '[01;30m:[0m'
+# sep = ansi['gray'] + ':' + ansi['default']
sep = ':'
else:
sys.stdout.write(self.format % self.val[name])
@@ -660,10 +663,25 @@ class dstat_sys(dstat):
def show(self):
for name in self.vars:
- sys.stdout.write('%5d' % self.val[name])
+ sys.stdout.write(self.format % self.val[name])
if name != self.vars[-1]:
sys.stdout.write(' ')
+class dstat_time(dstat):
+ def __init__(self):
+ self.name = 'time'
+ self.format = '%10d'
+ self.len = 10
+ self.nick = ('epoch',)
+ self.vars = ('epoch',)
+ self.init()
+
+ def stats(self):
+ self.val['epoch'] = time.time()
+
+ def show(self):
+ sys.stdout.write(self.format % self.val['epoch'])
+
ansi = {
'black': '\033[0;30m',
'darkred': '\033[0;31m',
@@ -723,15 +741,15 @@ def conv(max, var, base = 1024):
color = ('darkred', 'brown', 'darkgreen', 'darkblue', 'darkmagenta', 'darkcyan', 'silver', 'darkred', 'darkgreen')
c = 0
-# var = var / step
+ var = var / step
while True:
if len('%d' % round(long(var))) < max:
if not op.integer and len('%1.2f' % var) < max:
ret = '%1.2f' % var
elif not op.integer and len('%1.1f' % var) < max:
ret = '%1.1f' % var
else:
- ret = '%d' % round(var)
+ ret = '%d' % round(long(var))
break
var = var / base
c = c + 1
@@ -818,14 +836,15 @@ def main():
elif mod == 'proc': olist.append(dstat_proc())
elif mod == 'swap': olist.append(dstat_swap())
elif mod == 'sys': olist.append(dstat_sys())
+ elif mod == 'time': olist.append(dstat_time())
### Remove defect objects
for o in olist + []:
if not o.check():
olist.remove(o)
-# if os.geteuid() == 0:
-# os.nice(-10)
+ if os.geteuid() == 0:
+ os.nice(-10)
# sys.setcheckinterval(op.delay * 1.5 * 100)
signal.signal(signal.SIGALRM, handler)
while count != op.count:
View
6 dstat.spec
@@ -4,7 +4,7 @@
Summary: Versatile vmstat, iostat and ifstat replacement
Name: dstat
-Version: 0.5
+Version: 0.5.1
Release: 1
License: GPL
Group: System Environment/Base
@@ -64,8 +64,8 @@ interprete real-time data as easy as possible.
%{_bindir}/dstat
%changelog
-* Thu Nov 11 2004 Dag Wieers <dag@wieers.com> - 0.5-1
-- Updated to release 0.5.
+* Thu Nov 11 2004 Dag Wieers <dag@wieers.com> - 0.5.1-1
+- Updated to release 0.5.1.
* Tue Oct 26 2004 Dag Wieers <dag@wieers.com> - 0.4-1
- Initial package. (using DAR)

0 comments on commit ec5e8a2

Please sign in to comment.