Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cpu values are no longer snapshots

  • Loading branch information...
commit b7aa3e12fed7ba92c6593d7de4ff200a44a8d5e7 1 parent 022663e
@dagwieers authored
Showing with 10 additions and 7 deletions.
  1. +1 −0  ChangeLog
  2. +1 −3 TODO
  3. +8 −4 dstat
View
1  ChangeLog
@@ -6,6 +6,7 @@
- Color cpu, proc, tcp and udp stats too.
- Don't clear the line after restoring the cursor at the start (disable flickering).
- Better formatting for load and proc stats.
+- cpu stats are not longer snapshots but average over delay
* 0.5.5
- In fact, round() was not the problem, use str() instead. (Anton Blanchard)
View
4 TODO
@@ -16,6 +16,7 @@
+ Add mpstat information (-C 0,1,2)
+ Add icmp stats ?
+ Add ntp stats
++ Add nfs 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
@@ -24,8 +25,5 @@
+ 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 foo, -I 99, -N eth9 dstat should fail when it does not exist
-+ cpu is avg of begin and end snapshot, not avg of intermediate results (already better than vmstat though)
+ proc stat is a snapshot in time, not avg of intermediate results
-+ The number of newly created processes in the proc stat easily exceeds the allocated space (2 chars)
-+ OverflowError: float too large to convert (in conv()) still not fixed in all cases
+ Timer is not accurate on 2.6, every second there's a 1ms deviation (every 17mins -> 1sec)
View
12 dstat
@@ -244,7 +244,7 @@ class dstat:
elif self.format == '%ds':
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))
+ sys.stdout.write('%s' % conv(self.len, self.val[name] / step, 100))
elif self.format == '%f':
sys.stdout.write('%s' % conv(self.len, self.val[name], 1))
elif self.format == '%is':
@@ -277,6 +277,8 @@ class dstat_cpu(dstat):
return False
def stats(self):
+ if step == 1:
+ for name in self.vars: self.val[name] = 0
for line in open('/proc/stat', 'r').readlines():
l = line.split()
if len(l) <= 7 or l[0] != 'cpu': continue
@@ -289,7 +291,7 @@ class dstat_cpu(dstat):
self.cn2['softirq'] = long(l[7])
self.cn2['total'] = self.cn2['user'] + self.cn2['sys'] + self.cn2['idle'] + self.cn2['wait'] + self.cn2['hardirq'] + self.cn2['softirq']
for name in self.vars:
- self.val[name] = 100.0 * (self.cn2[name] - self.cn1[name]) / (self.cn2['total'] - self.cn1['total'])
+ self.val[name] = self.val[name] + 100.0 * (self.cn2[name] - self.cn1[name]) / (self.cn2['total'] - self.cn1['total'])
self.cn1.update(self.cn2)
class dstat_cpu24(dstat):
@@ -310,6 +312,8 @@ class dstat_cpu24(dstat):
return False
def stats(self):
+ if step == 1:
+ for name in self.vars: self.val[name] = 0
for line in open('/proc/stat', 'r').readlines():
l = line.split()
if len(l) < 4 or l[0] != 'cpu': continue
@@ -318,7 +322,7 @@ class dstat_cpu24(dstat):
self.cn2['idle'] = long(l[4])
self.cn2['total'] = self.cn2['user'] + self.cn2['sys'] + self.cn2['idle']
for name in self.vars:
- self.val[name] = 100.0 * (self.cn2[name] - self.cn1[name]) / (self.cn2['total'] - self.cn1['total'])
+ self.val[name] = self.val[name] + 100.0 * (self.cn2[name] - self.cn1[name]) / (self.cn2['total'] - self.cn1['total'])
self.cn1.update(self.cn2)
class dstat_disk(dstat):
@@ -877,7 +881,7 @@ def conv(max, var, base = 1024):
if step == op.delay:
color = ('red', 'yellow', 'green', 'blue', 'magenta', 'cyan', 'white', 'darkred', 'darkgreen')
else:
- color = ('darkred', 'darkyellow', 'darkgreen', 'darkblue', 'darkmagenta', 'darkcyan', 'silver', 'red', 'geen')
+ color = ('darkred', 'darkyellow', 'darkgreen', 'darkblue', 'darkmagenta', 'darkcyan', 'silver', 'red', 'green')
if base == 0:
if round(var) == 0:
Please sign in to comment.
Something went wrong with that request. Please try again.