Prebaked scripts for zpool status/iostat -c
commitd6418de057ecb71fb4cdc1b0a89d5265d13d121a
authorTony Hutter <hutter2@llnl.gov>
Fri, 21 Apr 2017 16:27:04 +0000 (21 09:27 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 21 Apr 2017 16:27:04 +0000 (21 09:27 -0700)
treebb4eec33de86e05bcc12d74ac7f8ff335ee45919
parent038091fd4f8d24f308708987192065e55574bbe9
Prebaked scripts for zpool status/iostat -c

This patch updates the "zpool status/iostat -c" commands to only run
"pre-baked" scripts from the /etc/zfs/zpool.d directory (or wherever
you install to).  The scripts can only be run from -c as an unprivileged
user (unless the ZPOOL_SCRIPTS_AS_ROOT environment var is
set by root).  This was done to encourage scripts to be written is such
a way that normal users can use them, and to be cautious.  If your
script needs to run a privileged command, consider adding the
appropriate line in /etc/sudoers.  See zpool(8) for an example of how
to do this.

The patch also allows the scripts to output custom column names.  If
the script outputs a line like:

name=value

then "name" is used for the column name, and "value" is its value.
Multiple columns can be specified by outputting multiple lines.  Column
names and values can have spaces.  If the value is empty, a dash (-) is
printed instead.

After all the "name=value" lines are read (if any), zpool will take the
next the next line of output (if any) and print it without a column
header.  After that, no more lines will be processed. This can be
useful for printing errors.

Lastly, this patch also disables the -c option with the latency and
request size histograms, since it produced awkward output and made the
code harder to maintain.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #5852
36 files changed:
Makefile.am
cmd/zpool/Makefile.am
cmd/zpool/zpool.d/README [new file with mode: 0644]
cmd/zpool/zpool.d/enc [new symlink]
cmd/zpool/zpool.d/encdev [new symlink]
cmd/zpool/zpool.d/fault_led [new symlink]
cmd/zpool/zpool.d/iostat [new file with mode: 0755]
cmd/zpool/zpool.d/iostat-10s [new symlink]
cmd/zpool/zpool.d/iostat-1s [new symlink]
cmd/zpool/zpool.d/label [new symlink]
cmd/zpool/zpool.d/locate_led [new symlink]
cmd/zpool/zpool.d/lsblk [new file with mode: 0755]
cmd/zpool/zpool.d/model [new symlink]
cmd/zpool/zpool.d/serial [new symlink]
cmd/zpool/zpool.d/ses [new file with mode: 0755]
cmd/zpool/zpool.d/size [new symlink]
cmd/zpool/zpool.d/slaves [new file with mode: 0755]
cmd/zpool/zpool.d/slot [new symlink]
cmd/zpool/zpool.d/upath [new file with mode: 0755]
cmd/zpool/zpool.d/vendor [new symlink]
cmd/zpool/zpool_iter.c
cmd/zpool/zpool_main.c
cmd/zpool/zpool_util.h
include/libzfs.h
lib/libzfs/libzfs_util.c
man/man8/zpool.8
rpm/generic/zfs.spec.in
tests/runfiles/linux.run
tests/zfs-tests/include/Makefile.am
tests/zfs-tests/include/default.cfg
tests/zfs-tests/include/zpool_script.shlib [new file with mode: 0755]
tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_003_pos.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh
tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_005_pos.ksh
zfs-script-config.sh.in