[dstat] Patch adding switches to display network / disk stats in bits instead of bytes.
Jan Zeleny
jzeleny at fedoraproject.org
Tue Aug 24 07:56:46 UTC 2010
commit 054becd4d5d8e2c54d8488320a7dfcdb0fc67a26
Author: Jan Zeleny <jzeleny at redhat.com>
Date: Tue Aug 24 09:55:53 2010 +0200
Patch adding switches to display network / disk stats in bits
instead of bytes.
dstat-0.7.2-bits.patch | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
dstat.spec | 8 +++-
2 files changed, 113 insertions(+), 1 deletions(-)
---
diff --git a/dstat-0.7.2-bits.patch b/dstat-0.7.2-bits.patch
new file mode 100644
index 0000000..2fe30ae
--- /dev/null
+++ b/dstat-0.7.2-bits.patch
@@ -0,0 +1,106 @@
+--- dstat-0.7.2/dstat.orig 2010-06-11 08:08:01.000000000 +0200
++++ dstat-0.7.2/dstat 2010-08-24 09:50:39.000000000 +0200
+@@ -90,6 +90,8 @@ class Options:
+ self.output = False
+ self.pidfile = False
+ self.profile = ''
++ self.netbits = False
++ self.diskbits = False
+
+ ### List of available plugins
+ allplugins = listplugins()
+@@ -111,9 +113,9 @@ class Options:
+ }
+
+ try:
+- opts, args = getopt.getopt(args, 'acdfghilmno:prstTvyC:D:I:M:N:S:V',
+- ['all', 'all-plugins', 'bw', 'blackonwhite', 'debug',
+- 'filesystem', 'float', 'full', 'help', 'integer',
++ opts, args = getopt.getopt(args, 'abcdfghilmno:prstTvyC:D:I:M:N:S:V',
++ ['all', 'all-plugins', 'bw', 'bits', 'blackonwhite', 'debug',
++ 'filesystem', 'float', 'full', 'help', 'integer', 'netbits', 'diskbits'
+ 'list', 'mods', 'modules', 'nocolor', 'noheaders', 'noupdate',
+ 'output=', 'pidfile=', 'profile', 'version', 'vmstat'] + allplugins)
+ except getopt.error, exc:
+@@ -179,6 +181,13 @@ class Options:
+ self.blackonwhite = True
+ elif opt in ['--debug']:
+ self.debug = self.debug + 1
++ elif opt in ['--bits', '-b']:
++ self.netbits = True
++ self.diskbits = True
++ elif opt in ['--netbits']:
++ self.netbits = True
++ elif opt in ['--diskbits']:
++ self.diskbits = True
+ elif opt in ['--float']:
+ self.float = True
+ elif opt in ['--integer']:
+@@ -268,9 +277,11 @@ Dstat options:
+ -C 0,3,total include cpu0, cpu3 and total
+ -d, --disk enable disk stats
+ -D total,hda include hda and total
++ --diskbits output disk stats in bits instead of bytes
+ -g, --page enable page stats
+ -i, --int enable interrupt stats
+ -I 5,eth2 include int5 and interrupt used by eth2
++ --netbits output net stats in bits instead of bytes
+ -l, --load enable load stats
+ -m, --mem enable memory stats
+ -n, --net enable network stats
+@@ -282,6 +293,7 @@ Dstat options:
+ -t, --time enable time/date output
+ -T, --epoch enable time counter (seconds since epoch)
+ -y, --sys enable system stats
++ -b, --bits output disk/net stats in bits instead of bytes
+
+ --aio enable aio stats
+ --fs, --filesystem enable fs stats
+@@ -719,6 +731,12 @@ class dstat_disk(dstat):
+ return ['dsk/'+sysfs_dev(name) for name in self.vars]
+
+ def extract(self):
++
++ # Default to 1.0 (leave as bytes) but if bits convert the bytes to bits
++ factor = 1.0
++ if op.diskbits:
++ factor = 8.0
++
+ for name in self.vars: self.set2[name] = (0, 0)
+ for l in self.splitlines():
+ if len(l) < 13: continue
+@@ -736,8 +754,8 @@ class dstat_disk(dstat):
+ self.set2[diskset] = ( self.set2[diskset][0] + long(l[5]), self.set2[diskset][1] + long(l[9]) )
+ for name in self.set2.keys():
+ self.val[name] = (
+- (self.set2[name][0] - self.set1[name][0]) * 512.0 / elapsed,
+- (self.set2[name][1] - self.set1[name][1]) * 512.0 / elapsed,
++ (self.set2[name][0] - self.set1[name][0]) * factor * 512.0 / elapsed,
++ (self.set2[name][1] - self.set1[name][1]) * factor * 512.0 / elapsed,
+ )
+ if step == op.delay:
+ self.set1.update(self.set2)
+@@ -1227,6 +1245,12 @@ class dstat_net(dstat):
+
+ def extract(self):
+ self.set2['total'] = [0, 0]
++
++ # Default to 1.0 (leave as bytes) but if bits convert the bytes to bits
++ factor = 1.0
++ if op.netbits:
++ factor = 8.0
++
+ for l in self.splitlines(replace=':'):
+ if len(l) < 17: continue
+ if l[2] == '0' and l[10] == '0': continue
+@@ -1238,8 +1262,8 @@ class dstat_net(dstat):
+ if update:
+ for name in self.set2.keys():
+ self.val[name] = [
+- (self.set2[name][0] - self.set1[name][0]) * 1.0 / elapsed,
+- (self.set2[name][1] - self.set1[name][1]) * 1.0 / elapsed,
++ (self.set2[name][0] - self.set1[name][0]) * factor / elapsed,
++ (self.set2[name][1] - self.set1[name][1]) * factor / elapsed,
+ ]
+ if self.val[name][0] < 0: self.val[name][0] += maxint + 1
+ if self.val[name][1] < 0: self.val[name][1] += maxint + 1
diff --git a/dstat.spec b/dstat.spec
index 5f6f7eb..d269ee6 100644
--- a/dstat.spec
+++ b/dstat.spec
@@ -4,13 +4,14 @@
Summary: Versatile resource statistics tool
Name: dstat
Version: 0.7.2
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2
Group: System Environment/Base
URL: http://dag.wieers.com/home-made/dstat/
Source: http://dag.wieers.com/home-made/dstat/dstat-%{version}.tar.bz2
Patch0: dstat-0.6.8-dbus.patch
+Patch1: dstat-0.7.2-bits.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root%(%{__id_u} -n)
BuildArch: noarch
@@ -35,6 +36,7 @@ confusion, less mistakes.
%prep
%setup -q
%patch0 -p1 -b .dbus
+%patch1 -p1 -b .bits
%build
# Make sure the docs are in unix format
@@ -65,6 +67,10 @@ cd docs
%{_datadir}/dstat/*.py*
%changelog
+* Tue Aug 24 2010 Jan Zeleny <jzeleny at redhat.com> - 0.7.2-3
+- patch adding options switching from bytes to bits when displaying
+ network and/or disk stats
+
* Wed Aug 11 2010 David Malcolm <dmalcolm at redhat.com> - 0.7.2-2
- recompiling .py files against Python 2.7 (rhbz#623287)
More information about the scm-commits
mailing list