raw filesystem counters

Miroslav Lachman 000.fbsd at quip.cz
Wed Jun 27 11:59:44 UTC 2018


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


More information about the freebsd-fs mailing list