20110511: raidcheck.sh
by dervish on May.11, 2011, under Scripts
#!/bin/bash
# raidcheck.sh – Search for SAS1064 or Adaptec AAC-RAID controller and report failed/degraded drives
#
# 20091222 jah – Created by Jamey Hopkins
# 20110511 jah – Added support for more than 1 drive. Still defaults to controller 1.
# rm UcliEvt.log
# Code/error message cleanup/clarification.
process_mpt-status() {
ID=`grep Found status.0 | cut -f2 -d= | cut -f1 -d,`
/usr/sbin/mpt-status -i $ID -s >status.1
C1=`cat status.1 | grep phys_id | wc -l`
C2=`cat status.1 | grep phys_id | grep ONLINE | wc -l`
[ “$C1” = “0” ] && echo “No Drives Found”
[ “$C1” = “$C2” ] && echo “$C2 of $C1 Drives Are Online”
#echo “Controller ID=$ID”
if [ $C2 -lt $C1 ]
then
echo “ERROR: Failed SAS Drive Found”
echo “$C2 of $C1 Drives Are ONLINE”
echo
exit 2
fi
}
AACRAID=”0″;SAS1064=”0″
# search for SAS1064 controller
DATA=`/sbin/lspci | grep SAS1064 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process SAS
SAS1064=”1″
# check if mptctl module is loaded
MPT=`/sbin/lsmod | grep mptctl 2>/dev/null`
[ ! -n “$MPT” ] && echo “mptctl module not loaded”
/usr/sbin/mpt-status -p >status.0 2>&1
grep “not found” status.0 >/dev/null
if [ “$?” = “0” -a ! -n “$MPT” ]
then
echo “mpt-status not found in /usr/sbin”
else
process_mpt-status
fi
fi
# search for Adaptec AAC-RAID controller
DATA=`/sbin/lspci | grep AAC-RAID 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process AAC-RAID
AACRAID=”1″
STATE=`/usr/StorMan/arcconf getconfig 1 | grep “Logical devices/Failed/Degraded” | cut -f2 -d: | xargs echo`
#echo state is -${STATE}-
#STATE=”1/0/1″ # Set STATE for Testing
STATE2=`echo $STATE | cut -f2 -d’/’`
STATE3=`echo $STATE | cut -f3 -d’/’`
if [ “$STATE2” != “0” -o “$STATE3” != “0” ]
then
echo “ERROR: AAC-RAID Error – Devices/Failed/Degraded $STATE”
echo
exit 2
else
echo “AAC-RAID: No Failed or Degraded Drives Found.”
fi
fi
if [ $SAS1064 = 0 -a $AACRAID = 0 ]
then
echo “No supported controllers found.”
fi
rm status.0 status.1 >/dev/null 2>&1
rm UcliEvt.log >/dev/null 2>&1
exit 0
Leave a Reply
You must be logged in to post a comment.
May 11th, 2011 on 5:05 pm
[…] # raidcheck.sh – search for SAS1064 or Adaptec AAC-RAID controller and report failed drives # # Created 20091222 Jamey Hopkins # Note: replaced by 20110511: raidcheck.sh […]