1#!/bin/sh 2# 3# Print SCSI Enclosure Services (SES) info. The output is dependent on the name 4# of the script/symlink used to call it. 5# 6helpstr=" 7enc: Show disk enclosure w:x:y:z value. 8slot: Show disk slot number as reported by the enclosure. 9encdev: Show /dev/sg* device associated with the enclosure disk slot. 10fault_led: Show value of the disk enclosure slot fault LED. 11locate_led: Show value of the disk enclosure slot locate LED. 12ses: Show disk's enc, enc device, slot, and fault/locate LED values." 13 14script="${0##*/}" 15if [ "$1" = "-h" ] ; then 16 echo "$helpstr" | grep "$script:" | tr -s '\t' | cut -f 2- 17 exit 18fi 19 20if [ "$script" = "ses" ] ; then 21 scripts='enc encdev slot fault_led locate_led' 22else 23 scripts="$script" 24fi 25 26for i in $scripts ; do 27 if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then 28 echo "$i=" 29 continue 30 fi 31 32 val="" 33 case $i in 34 enc) 35 if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then 36 val="$VDEV_ENC_SYSFS_PATH" 37 else 38 val="$(ls """$VDEV_ENC_SYSFS_PATH/../../""" 2>/dev/null)" 39 fi 40 ;; 41 slot) 42 if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then 43 val="$(basename """$VDEV_ENC_SYSFS_PATH""")" 44 else 45 val="$(cat """$VDEV_ENC_SYSFS_PATH/slot""" 2>/dev/null)" 46 fi 47 ;; 48 encdev) 49 val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null) 50 ;; 51 fault_led) 52 # JBODs fault LED is called 'fault', NVMe fault LED is called 53 # 'attention'. 54 if [ -f "$VDEV_ENC_SYSFS_PATH/fault" ] ; then 55 val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null) 56 elif [ -f "$VDEV_ENC_SYSFS_PATH/attention" ] ; then 57 val=$(cat "$VDEV_ENC_SYSFS_PATH/attention" 2>/dev/null) 58 fi 59 ;; 60 locate_led) 61 val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null) 62 ;; 63 esac 64 echo "$i=$val" 65done 66 67