[tools] dstat -fd semi-broken on latest kernels
Peter Rabbitson
rabbit+list at rabbit.us
Wed Oct 29 11:15:24 CET 2008
Dag Wieers wrote:
> On Wed, 29 Oct 2008, Peter Rabbitson wrote:
>
>> Dag Wieers wrote:
>>> On Tue, 28 Oct 2008, Peter Rabbitson wrote:
>>>
>>>> Yesterday I upgraded from 2.6.23 to 2.6.27. Now dstat -fd shows all
>>>> disks _and_ all their partitions as well, requiring a super-wide
>>>> terminal to operate. As I have 7 physical drives, enumerating them
>>>> to -D
>>>> is problematic. Is there some workaround for this (and what exactly is
>>>> causing it anyway)?
>>>
>>> In the pasts partitions did not have the same counters as disks. So it
>>> was very easy to ignore partitions: remove all devices that have no (or
>>> zero) counters.
>>>
>>> Apparently we finally have counters for partitions, so I guess we'll
>>> have to look at another way to get rid of the partitions ;-) Care to
>>> send me the output of /proc/diskstats ?
>>>
>>> It will not be easy to make the distinction unless I assume that only
>>> certain block devices that are enumerated are partitions (eg. sda1,
>>> hda2) but not others (eg. ram1, md1).
>>>
>>
>> Both /proc/partitions and /proc/diskstats are useless to you (see
>> below). However I think you can get away by parsing /sys/block (and
>> there is 99% chance it is mounted on a system running something as
>> advanced as 2.6.27):
>>
>> dominus at Arzamas:~$ ls /sys/block/
>> dm-0 dm-1 fd0 md0 md1 sda sdb sdc sdd sde sr0
>> dominus at Arzamas:~$
>
> Great !
>
> Can you test this patch ?
>
> It should by default only select the block devices without partitions.
> But still allow you to select individual partitions as well.
>
> Thanks in advance,
It didn't work out of the box, but with tweaking it does what's needed.
Please review the patch below. Also I would like to ask about the fate
of a patch I submitted twice over the course of a year:
http://lists.rpmforge.net/pipermail/tools/2008-October/001293.html
Although it needs some TLC to accommodate latest changes, I would like
to know if the idea is generally unacceptable, so I will quit trying :))
The -fd patch:
Index: dstat
===================================================================
--- dstat (revision 6528)
+++ dstat (working copy)
@@ -24,7 +24,7 @@
try:
import sys, os, time, sched, re
- import types, resource, getpass
+ import types, resource, getpass, glob
inspath('/usr/local/share/dstat/')
inspath('/usr/share/dstat/')
inspath(os.path.abspath(os.path.dirname(sys.argv[0])) +
'/plugins/') # binary path + /plugins/
@@ -612,9 +612,11 @@
list = ('total',)
else:
list = []
+ devlist = [(os.path.basename(file)) for file in
glob.glob('/sys/block/*')]
for name in self.discover:
- if not re.match('(md[0-9]+|dm-[0-9]+)', name):
- list.append(name)
+ if re.match('(md[0-9]+|dm-[0-9]+)', name): continue
+ if len(devlist) > 0 and name not in devlist: continue
+ list.append(name)
# if len(list) > 2: list = list[0:2]
list.sort()
for name in list:
More information about the tools
mailing list