diff options
author | Tony Hutter <[email protected]> | 2016-11-29 13:45:38 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-11-29 14:45:38 -0700 |
commit | 8720e9e7482fa2dce4f34c56d3c7451833413d7d (patch) | |
tree | 2475bb498ab7bc8e5fb016dbca1a337d10f257c5 /man | |
parent | 2f71caf2d926249920d1b9162550c56715cc6461 (diff) |
Add -c to zpool iostat & status to run command
This patch adds a command (-c) option to zpool status and zpool iostat. The
-c option allows you to run an arbitrary command on each vdev and display
the first line of output in zpool status/iostat. The environment vars
VDEV_PATH and VDEV_UPATH are set to the vdev's path and "underlying path"
before running the command. For device mapper, multipath, or partitioned
vdevs, VDEV_UPATH is the actual underlying /dev/sd* disk. This can be useful
if the command you're running requires a /dev/sd* device.
The patch also uses /sys/block/<dev>/slaves/ to lookup the underlying device
instead of using libdevmapper. This not only removes the libdevmapper
requirement at build time, but also allows you to resolve device mapper
devices without being root. This means that UDEV_UPATH get set correctly
when running zpool status/iostat as an unprivileged user.
Example:
$ zpool status -c 'echo I am $VDEV_PATH, $VDEV_UPATH'
NAME STATE READ WRITE CKSUM
mypool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
mpatha ONLINE 0 0 0 I am /dev/mapper/mpatha, /dev/sdc
sdb ONLINE 0 0 0 I am /dev/sdb1, /dev/sdb
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #5368
Diffstat (limited to 'man')
-rw-r--r-- | man/man8/zpool.8 | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/man/man8/zpool.8 b/man/man8/zpool.8 index 42e5c28d2..883d11739 100644 --- a/man/man8/zpool.8 +++ b/man/man8/zpool.8 @@ -96,7 +96,7 @@ zpool \- configures ZFS storage pools .LP .nf -\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [\fB-lq\fR]|[\fB-r\fR|-\fBw\fR]] +\fB\fBzpool iostat\fR [\fB-c\fR \fBCMD\fR] [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [\fB-lq\fR]|[\fB-r\fR|-\fBw\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR .fi @@ -159,7 +159,7 @@ zpool \- configures ZFS storage pools .LP .nf -\fBzpool status\fR [\fB-gLPvxD\fR] [\fB-T\fR d | u] [\fIpool\fR] ... [\fIinterval\fR [\fIcount\fR]] +\fBzpool status\fR [\fB-c\fR \fBCMD\fR] [\fB-gLPvxD\fR] [\fB-T\fR d | u] [\fIpool\fR] ... [\fIinterval\fR [\fIcount\fR]] .fi .LP @@ -1523,7 +1523,7 @@ Scan using the default search path, the libblkid cache will not be consulted. A .sp .ne 2 .na -\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [[\fB-lq\fR]|[\fB-r\fR|\fB-w\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR +\fB\fBzpool iostat\fR [\fB-c\fR \fBCMD\fR] [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-ghHLpPvy\fR] [[\fB-lq\fR]|[\fB-r\fR|\fB-w\fR]] [[\fIpool\fR ...]|[\fIpool vdev\fR ...]|[\fIvdev\fR ...]] [\fIinterval\fR[\fIcount\fR]]\fR .ad .sp .6 @@ -1542,6 +1542,23 @@ base 1024. To get the raw values, use the \fB-p\fR flag. .sp .ne 2 .na +\fB\fB-c\fR \fBCMD\fR +.ad +.RS 12n +Run a command on each vdev and include first line of output +.sp +The \fB-c\fR option allows you to run an arbitrary command on each vdev and +display the first line of output in zpool iostat. The environment vars +\fBVDEV_PATH\fR and \fBVDEV_UPATH\fR are set to the vdev's path and "underlying +path" before running the command. For device mapper, multipath, or partitioned +vdevs, \fBVDEV_UPATH\fR is the actual underlying /dev/sd* disk. This can be +useful if the command you're running requires a /dev/sd* device. Commands run +in parallel for each vdev for performance. +.RE + +.sp +.ne 2 +.na \fB\fB-T\fR \fBu\fR | \fBd\fR\fR .ad .RS 12n @@ -2082,7 +2099,7 @@ Sets the specified property for \fInewpool\fR. See the “Properties” section .sp .ne 2 .na -\fBzpool status\fR [\fB-gLPvxD\fR] [\fB-T\fR d | u] [\fIpool\fR] ... [\fIinterval\fR [\fIcount\fR]] +\fBzpool status\fR [\fB-c\fR \fBCMD\fR] [\fB-gLPvxD\fR] [\fB-T\fR d | u] [\fIpool\fR] ... [\fIinterval\fR [\fIcount\fR]] .ad .sp .6 .RS 4n @@ -2093,6 +2110,23 @@ If a scrub or resilver is in progress, this command reports the percentage done .sp .ne 2 .na +\fB\fB-c\fR \fBCMD\fR +.ad +.RS 12n +Run a command on each vdev and include first line of output +.sp +The \fB-c\fR option allows you to run an arbitrary command on each vdev and +display the first line of output in zpool status. The environment vars +\fBVDEV_PATH\fR and \fBVDEV_UPATH\fR are set to the vdev's path and "underlying +path" before running the command. For device mapper, multipath, or partitioned +vdevs, \fBVDEV_UPATH\fR is the actual underlying /dev/sd* disk. This can be +useful if the command you're running requires a /dev/sd* device. Commands run +in parallel for each vdev for performance. +.RE + +.sp +.ne 2 +.na \fB\fB-g\fR\fR .ad .RS 12n @@ -2519,6 +2553,40 @@ data 23.9G 14.6G 9.30G 48% - 61% 1.00x ONLINE - c1t3d0 - - - - - .fi .in -2 +.sp + +.LP +\fBExample 16 \fRRunning commands in zpool status and zpool iostat with -c +.sp +.LP +Some examples of using the command (-c) option with zpool status and zpool +iostat: +.sp +.in +2 +.nf +# \fBzpool status -c \[aq]echo I am $VDEV_PATH, $VDEV_UPATH\[aq]\fR +NAME STATE READ WRITE CKSUM +mypool ONLINE 0 0 0 + mirror-0 ONLINE 0 0 0 + mpatha ONLINE 0 0 0 I am /dev/mapper/mpatha, /dev/sdc + sdb ONLINE 0 0 0 I am /dev/sdb1, /dev/sdb +.fi +.in -2 + +.sp +.in +2 +.nf +# \fBzpool iostat -v -c \[aq]smartctl -a $VDEV_UPATH | grep "Current Drive Temperature"\[aq]\fR +mypool 997M 7.25T 0 0 105K 106K + mirror 997M 7.25T 0 0 105K 106K + B0 - - 0 0 17.4K 15.2K Current Drive Temperature: 25 C + B1 - - 0 0 17.4K 15.2K Current Drive Temperature: 24 C + B2 - - 0 0 17.5K 15.2K Current Drive Temperature: 24 C + B3 - - 0 0 0 15.1K Current Drive Temperature: 24 C +logs - - - - - - + B8 0 7.25T 0 0 1.14K 20.2K Current Drive Temperature: 23 C +.fi +.in -2 .SH EXIT STATUS .sp |