Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jun 2018 13:59:34 +0200
From:      Miroslav Lachman <000.fbsd@quip.cz>
To:        "E.S. Rosenberg" <esr+freebsd-fs@mail.hebrew.edu>, "Eric A. Borisch" <eborisch@gmail.com>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: raw filesystem counters
Message-ID:  <52505cfc-f656-f761-e92c-8a4be2c78fbf@quip.cz>
In-Reply-To: <CA%2BK1OzRC38ORiO61hLGtYLseuEPQk=LGT6teMTUMxhQHuaYGXg@mail.gmail.com>
References:  <CA%2BK1OzSda42zBCfT4n0_DScf74TsJyHsxBHaxZwcjkOe3ccmwA@mail.gmail.com> <CAASnNnrYjYYijrBtz-bkxvMTa9ugYYLuiDtLNJM1gFJENdjYRg@mail.gmail.com> <CA%2BK1OzSyF=E8CZgn=JSYOW4XPwnLWxYGHt7Xp9ZrvrXnECy2Rg@mail.gmail.com> <CAASnNnovT3ByaJpijFSsKqtc9fc08-j0wHBKsJWX5rwpbzavDg@mail.gmail.com> <CA%2BK1OzRC38ORiO61hLGtYLseuEPQk=LGT6teMTUMxhQHuaYGXg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
E.S. Rosenberg wrote on 2018/06/27 04:22:
> //I hope it's not considered a problem that I'm reviving this old thread.
> 
> That is a really cool patch thanks!
> Will see if I can get the ZFS admins to allow me to use it...
> 
> A small follow up question:
> Is there any easily parsable way to find what disks are part of a pool?
> zpool status poolname is a nightmare to parse.
> 
> Your patched output would be slightly better to parse but still not ideal
> because depending on whether or not disks are in raidz or not they may be
> more or less indented...

You are not using nested vdevs then you can use relatively simple 
parsing method

 From this standard output

# zpool status tank0
   pool: tank0
  state: ONLINE
   scan: scrub repaired 0 in 160h57m with 0 errors on Wed Jun  6 
20:02:52 2018
config:

         NAME                STATE     READ WRITE CKSUM
         tank0               ONLINE       0     0     0
           raidz1-0          ONLINE       0     0     0
             gpt/disk0tank0  ONLINE       0     0     0
             gpt/disk1tank0  ONLINE       0     0     0
             gpt/disk2tank0  ONLINE       0     0     0
             gpt/disk3tank0  ONLINE       0     0     0

errors: No known data errors

You can get the list of devices by this ugly command.
(it can be somewhat optimised, I wrote it now in a minute, just as an 
example)

# zpool status tank0 | sed -n '/NAME/,/^$/p' | tail -n +4 | awk '$1 != 
"" { print $1 }'
gpt/disk0tank0
gpt/disk1tank0
gpt/disk2tank0
gpt/disk3tank0


sed -n '/NAME/,/^$/p' - this will take the part of the original output 
from header line starting with word NAME till the first blank line

tail -n +4 - this will take the part from the fourth line (skipping NAME 
line, tank0 line and raidz1-0 line)

Now you have the disks, awk will print just their names, skipping last 
empty line of output.

And if you need some ugly oneliner the get the stats...

# gstat -b -I 5s -f `zpool status tank0 | sed -n '/NAME/,/^$/p' | tail 
-n +4 | awk '$1 != "" { if (disk != "") { disk=disk"|"$1 } else { 
disk=$1 } } END { print disk }'`
dT: 5.004s  w: 5.000s  filter: 
gpt/disk0tank0|gpt/disk1tank0|gpt/disk2tank0|gpt/disk3tank0
  L(q)  ops/s    r/s   kBps   ms/r    w/s   kBps   ms/w   %busy Name
     0      0      0      0    0.0      0      0    0.0    0.0 
gpt/disk0tank0
     0      0      0      0    0.0      0      0    0.0    0.0 
gpt/disk2tank0
     0      0      0      0    0.0      0      0    0.0    0.0 
gpt/disk1tank0
     0      0      0      0    0.0      0      0    0.0    0.0 
gpt/disk3tank0

Miroslav Lachman



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52505cfc-f656-f761-e92c-8a4be2c78fbf>