Create a gist now

Instantly share code, notes, and snippets.

Embed
1. LSI Logic / Symbios Logic MegaRAID SAS 2208 2. LSI Logic / Symbios Logic MegaRAID SAS 9240 3. LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2
#!/bin/bash
# Checkresults are returned as text or integer.
# The script expects one parameter: The check you want to perform .
# The second paramter, the value you want to grep, is optional.
# The third parameter, the adapter number, is optional. If adapter number is missing, ALL is set.
# Thanks to https://twiki.cern.ch/twiki/bin/view/FIOgroup/DiskRefPerc
# for the nice overview
# LSI Logic / Symbios Logic MegaRAID SAS 2208
# LSI Logic / Symbios Logic MegaRAID SAS 9240
# LSI Logic / Symbios Logic SAS2008 PCI-Express Fusion-MPT SAS-2
MEGACLI_BIN=/opt/MegaRAID/MegaCli/MegaCli64
MEGACLI="sudo $MEGACLI_BIN"
# Check if Megacli is installed and executable
if [ -e $MEGACLI_BIN ]
then
true
else
echo "Megacli missing";
exit 1
fi
# Set the adapternumber
if [ $3 ]
then
ADAPTER=$3
else
ADAPTER=ALL
fi
COUNT=$($MEGACLI -adpCount|grep "Controller Count"|grep -o "[0-9]*")
if [ $COUNT -lt 1 ]
then
echo "No compatible adapter"
exit 1
fi
case $1 in
batterystate)
$MEGACLI -AdpBbuCmd -GetBbuStatus -a${ADAPTER} | grep -c "Battery State: Optimal"
;;
isSOHGood)
$MEGACLI -AdpBbuCmd -GetBbuStatus -a${ADAPTER} | grep -c "isSOHGood: Yes"
;;
adapter)
$MEGACLI -adpallinfo -a${ADAPTER} | grep "Errors " | grep -cv ": 0"
;;
mediaerrors)
$MEGACLI -PDList -a${ADAPTER} | grep "Media Error Count" | grep -cv "Media Error Count: 0"
;;
raiderrors)
$MEGACLI -LDInfo -Lall -a${ADAPTER} | grep State | grep -vc Optimal
;;
alarm)
$MEGACLI -AdpAllInfo -a${ADAPTER} | grep -i Alarm | head -n1 | grep -cv "Alarm.*Absent"
;;
adapters)
echo $COUNT
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment