[dstat] enable to specify disks with path (symlink) to device file
Jiří Popelka
jpopelka at fedoraproject.org
Mon Dec 12 16:37:44 UTC 2011
commit 306cf3087031f1ba7f258a276ba40ad35998e6e6
Author: Jiri Popelka <jpopelka at redhat.com>
Date: Mon Dec 12 17:34:28 2011 +0100
enable to specify disks with path (symlink) to device file
modernize spec
dstat-0.7.2-disk-path.patch | 45 +++++++++++++++++++++++++++++++++++++++++++
dstat.spec | 30 ++++++++++++++++++++++------
2 files changed, 68 insertions(+), 7 deletions(-)
---
diff --git a/dstat-0.7.2-disk-path.patch b/dstat-0.7.2-disk-path.patch
new file mode 100644
index 0000000..0f0269f
--- /dev/null
+++ b/dstat-0.7.2-disk-path.patch
@@ -0,0 +1,45 @@
+diff -up dstat-0.7.2/dstat.disk-path dstat-0.7.2/dstat
+--- dstat-0.7.2/dstat.disk-path 2011-12-12 17:25:23.000000000 +0100
++++ dstat-0.7.2/dstat 2011-12-12 16:15:33.000000000 +0100
+@@ -130,7 +130,7 @@ class Options:
+ elif opt in ['-d']:
+ self.plugins.append('disk')
+ elif opt in ['-D']:
+- self.disklist = arg.split(',')
++ self.disklist = self.get_disklist(arg)
+ elif opt in ['--filesystem']:
+ self.plugins.append('fs')
+ elif opt in ['-g']:
+@@ -240,6 +240,32 @@ class Options:
+ print 'dstat: delay must be an integer, greater than zero'
+ sys.exit(1)
+
++ def get_disklist(self, disks):
++ disklist = disks.split(',')
++ ret = []
++ for disk in disklist:
++ # e.g. /dev/sda1
++ if disk[:5] == '/dev/':
++ # file or symlink
++ if os.path.exists(disk):
++ # e.g. /dev/disk/by-uuid/15e40cc5-85de-40ea-b8fb-cb3a2eaf872
++ if os.path.islink(disk):
++ target = os.readlink(disk)
++ # convert relative pathname to absolute
++ if target[0] != '/':
++ target = os.path.join(os.path.dirname(disk), target)
++ target = os.path.normpath(target)
++ print 'dstat: symlink %s -> %s' % (disk, target)
++ disk = target
++ # trim leading /dev/
++ disk = disk[5:]
++ ret.append(disk)
++ else:
++ print 'dstat: %s does not exist' % disk
++ else:
++ ret.append(disk)
++ return ret
++
+ def version(self):
+ print 'Dstat %s' % VERSION
+ print 'Written by Dag Wieers <dag at wieers.com>'
diff --git a/dstat.spec b/dstat.spec
index c1c5321..e5b0131 100644
--- a/dstat.spec
+++ b/dstat.spec
@@ -4,18 +4,32 @@
Summary: Versatile resource statistics tool
Name: dstat
Version: 0.7.2
-Release: 4%{?dist}
+Release: 5%{?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
+
+# Is there any BZ for this ?
Patch0: dstat-0.6.8-dbus.patch
+
+# patch adding options switching from bytes to bits when displaying network and/or disk stats
+# Is there any BZ for this ?
Patch1: dstat-0.7.2-bits.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root%(%{__id_u} -n)
+
+# This patch enables to specify disks with path to device file
+# (or with symbolic link to the device file)
+# For example:
+# dstat -d -D /dev/vda2
+# dstat -d -D /dev/disk/by-id/scsi-SATA_Hitachi_HDP7250_GEA534RF3YYMMA-part3
+# dstat -d -D /dev/disk/by-path/pci-0000:00:06.0-virtio-pci-virtio3-part2
+# dstat -d -D /dev/disk/by-uuid/6df45ed6-c4ad-4054-955d-b15102f2c566
+# (BZ#766443)
+Patch2: dstat-0.7.2-disk-path.patch
BuildArch: noarch
-BuildRequires: python
+BuildRequires: python2-devel
Requires: python
%description
@@ -37,6 +51,7 @@ confusion, less mistakes.
%setup -q
%patch0 -p1 -b .dbus
%patch1 -p1 -b .bits
+%patch2 -p1 -b .disk-path
%build
# Make sure the docs are in unix format
@@ -46,7 +61,6 @@ confusion, less mistakes.
%{__chmod} a-x examples/*
%install
-%{__rm} -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}
# Install the man page
cd docs
@@ -55,11 +69,8 @@ cd docs
%{__chmod} a-x %{buildroot}/%{_datadir}/dstat/*.py
%{__chmod} a+x %{buildroot}/%{_datadir}/dstat/dstat.py
-%clean
-%{__rm} -rf %{buildroot}
%files
-%defattr(-, root, root, 0755)
%dir %{_datadir}/dstat
%doc AUTHORS ChangeLog COPYING README TODO docs/*.html docs/*.txt examples/
%{_mandir}/man1/dstat.1*
@@ -67,6 +78,11 @@ cd docs
%{_datadir}/dstat/*.py*
%changelog
+* Tue Nov 08 2011 Jiri Popelka <jpopelka at redhat.com> - 0.7.2-5
+- enable to specify disks with path to device file or
+ with symbolic link to the device file (#766443)
+- modernize spec
+
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.7.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
More information about the scm-commits
mailing list