2017-04-21 19:27:04 +03:00
|
|
|
#!/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.
|
2017-06-05 20:52:15 +03:00
|
|
|
encdev: Show /dev/sg* device associated with the enclosure disk slot.
|
|
|
|
fault_led: Show value of the disk enclosure slot fault LED.
|
|
|
|
locate_led: Show value of the disk enclosure slot locate LED.
|
|
|
|
ses: Show disk's enc, enc device, slot, and fault/locate LED values."
|
2017-04-21 19:27:04 +03:00
|
|
|
|
2021-11-11 23:27:37 +03:00
|
|
|
script="${0##*/}"
|
2017-04-21 19:27:04 +03:00
|
|
|
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
|
2022-01-07 03:07:54 +03:00
|
|
|
# shellcheck disable=SC2154
|
2017-04-21 19:27:04 +03:00
|
|
|
if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then
|
|
|
|
echo "$i="
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
val=""
|
|
|
|
case $i in
|
|
|
|
enc)
|
2023-11-07 20:09:24 +03:00
|
|
|
if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
|
|
|
|
val="$VDEV_ENC_SYSFS_PATH"
|
|
|
|
else
|
|
|
|
val="$(ls """$VDEV_ENC_SYSFS_PATH/../../""" 2>/dev/null)"
|
|
|
|
fi
|
2017-04-21 19:27:04 +03:00
|
|
|
;;
|
|
|
|
slot)
|
2023-11-07 20:09:24 +03:00
|
|
|
if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
|
|
|
|
val="$(basename """$VDEV_ENC_SYSFS_PATH""")"
|
|
|
|
else
|
|
|
|
val="$(cat """$VDEV_ENC_SYSFS_PATH/slot""" 2>/dev/null)"
|
|
|
|
fi
|
2017-04-21 19:27:04 +03:00
|
|
|
;;
|
|
|
|
encdev)
|
|
|
|
val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null)
|
|
|
|
;;
|
|
|
|
fault_led)
|
2021-11-10 03:50:18 +03:00
|
|
|
# JBODs fault LED is called 'fault', NVMe fault LED is called
|
|
|
|
# 'attention'.
|
|
|
|
if [ -f "$VDEV_ENC_SYSFS_PATH/fault" ] ; then
|
|
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null)
|
|
|
|
elif [ -f "$VDEV_ENC_SYSFS_PATH/attention" ] ; then
|
|
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/attention" 2>/dev/null)
|
|
|
|
fi
|
2017-04-21 19:27:04 +03:00
|
|
|
;;
|
|
|
|
locate_led)
|
|
|
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null)
|
|
|
|
;;
|
2022-01-07 03:07:54 +03:00
|
|
|
*)
|
|
|
|
val=invalid
|
|
|
|
;;
|
2017-04-21 19:27:04 +03:00
|
|
|
esac
|
|
|
|
echo "$i=$val"
|
|
|
|
done
|