mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-29 12:29:35 +03:00
d6418de057
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
53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Print SCSI Enclosure Services (SES) info. The output is dependent on the name
|
|
# of the script/symlink used to call it.
|
|
#
|
|
helpstr="
|
|
enc: Show disk enclosure w:x:y:z value.
|
|
slot: Show disk slot number as reported by the enclosure.
|
|
encdev: Show the /dev/sg* device for the enclosure associated with the disk slot.
|
|
fault_led: Show the value of the disk enclosure slot fault LED.
|
|
locate_led: Show the value of the disk enclosure slot locate LED.
|
|
ses: Show disk's enclosure, enclosure dev, slot number, and fault/locate LED values."
|
|
|
|
script=$(basename "$0")
|
|
if [ "$1" = "-h" ] ; then
|
|
echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2-
|
|
exit
|
|
fi
|
|
|
|
if [ "$script" = "ses" ] ; then
|
|
scripts='enc encdev slot fault_led locate_led'
|
|
else
|
|
scripts="$script"
|
|
fi
|
|
|
|
for i in $scripts ; do
|
|
if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then
|
|
echo "$i="
|
|
continue
|
|
fi
|
|
|
|
val=""
|
|
case $i in
|
|
enc)
|
|
val=$(ls "$VDEV_ENC_SYSFS_PATH/../../" 2>/dev/null)
|
|
;;
|
|
slot)
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/slot" 2>/dev/null)
|
|
;;
|
|
encdev)
|
|
val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null)
|
|
;;
|
|
fault_led)
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null)
|
|
;;
|
|
locate_led)
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null)
|
|
;;
|
|
esac
|
|
echo "$i=$val"
|
|
done
|
|
|