4
# Script to blink the LED on a SAS disk.
5
# By default it blinks the LED for 30 seconds, thereafter leaving
6
# the LED in the state it was prior to this command being called.
7
# The blink is one second on, one second off, etc.
9
# Uses sdparm rather than sg3_utils as the former is simpler to
10
# use for setting mode page value.
12
# Douglas Gilbert 20070317
19
echo "Usage: sas_disk_blink [-h] [-s <n>] <sas_device>"
21
echo " -h, --help print usage message"
22
echo " -s <n>, --set <n> where <n> is:"
23
echo " 0 - set RLM to 0"
24
echo " 1 - set RLM to 1"
25
echo " >1 - blink LED for <n> seconds"
26
echo " (default: blink for 30 seconds)"
28
echo "Use Ready LED Meaning (RLM) mode page field to blink SAS device LED"
38
while test ! -z "$opt" -a -z "${opt##-*}"; do
41
h|-help) usage ; exit 0 ;;
42
s|-set) shift ; let seconds=$1 ;;
43
*) echo "Unknown option: -$opt " ; exit 1 ;;
49
if ( which sdparm >/dev/null 2>&1 ) ; then
52
echo "sdparm not found"
58
sdparm -t sas -c RLM $1
60
elif [ $seconds = "1" ]
62
sdparm -t sas -s RLM $1
64
elif [ $seconds -gt 1 ]
66
outt=$(sdparm -t sas -g RLM -H $1)
72
if [ ${outt:0:4} = "0x00" ]
78
echo "start blinking for $seconds seconds"
79
for (( times = 1; times < $seconds; times=$times+2 )); do
82
sdparm -q -t sas -s RLM $1
89
sdparm -q -t sas -c RLM $1
92
sdparm -q -t sas -c RLM $1
99
sdparm -q -t sas -s RLM $1