From owner-freebsd-fs@freebsd.org Wed Jun 27 11:59:44 2018 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56E59101F334 for ; Wed, 27 Jun 2018 11:59:44 +0000 (UTC) (envelope-from SRS0=7/i7=JN=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF01279C2C for ; Wed, 27 Jun 2018 11:59:43 +0000 (UTC) (envelope-from SRS0=7/i7=JN=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 6C7F628412; Wed, 27 Jun 2018 13:59:36 +0200 (CEST) Received: from illbsd.quip.test (ip-86-49-16-209.net.upcbroadband.cz [86.49.16.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 45BA32840C; Wed, 27 Jun 2018 13:59:35 +0200 (CEST) Subject: Re: raw filesystem counters To: "E.S. Rosenberg" , "Eric A. Borisch" Cc: freebsd-fs@freebsd.org References: From: Miroslav Lachman <000.fbsd@quip.cz> Message-ID: <52505cfc-f656-f761-e92c-8a4be2c78fbf@quip.cz> Date: Wed, 27 Jun 2018 13:59:34 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2018 11:59:44 -0000 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