Mini Shell

Direktori : /opt/sharedrads/
Upload File :
Current File : //opt/sharedrads/check_raid

#!/bin/bash
# RADS Tools, written by Erik Soroka (eriks@imhadmin.net, ext 834)
# RADS tool to check for RAID status and common problems that cause degraded I/O
# Some original code was forked off of the check_hardware nagios plugin


#load functions + banners
source /opt/sharedrads/radsfunctions.sh

if [ "$RADSCOLORS" == "off" ]; then
        radsbanner-nocolor
else
    	radsbanner
fi

#set some variables
SESSIONID=`date +%s`
MCELOG=/var/log/mcelog
ARCH=$(uname -p)

#lets set status colors
RED="\033[31;3;1m"
GREEN="\033[31;32;1m"
NORM="\033[0m"

if [ "$ARCH" == "x86_64" ];then
        MEGAPATH="/opt/MegaRAID/MegaCli/MegaCli64"
else
        MEGAPATH="/opt/MegaRAID/MegaCli/MegaCli"
fi

if [ -f $MEGAPATH ];then

	echo

	#Check RAID health status
        DRIVES_OK=$(sudo $MEGAPATH -LDInfo -Lall -aALL | egrep "Adapter|Name|State" | grep Optimal | wc -l);
        if [ "$DRIVES_OK" -lt "1" ]; then
                echo -e "RAID Array Health State:\t Degraded\t\t [$RED FAILED $NORM]"
	else
                echo -e "RAID Array Health State:\t Optimal\t\t [$GREEN PASSED $NORM]"
	fi

	#Check current Disk Cache policy (WT/WB)
        CACHE_OK=$(sudo $MEGAPATH -LDInfo -LAll -a0 | grep -A 2 "Span Depth" | grep "Current Cache" | awk '$0~/Current Cache Policy/ {print $4}' | grep "WriteThrough" | wc -l)
        if [ "$CACHE_OK" -eq 0 ]; then
                echo -e "Current Disk Cache Policy:\t Write Back\t\t [$GREEN PASSED $NORM]"
	else
                echo -e "Current Disk Cache Policy:\t WriteThrough\t\t [$RED FAILED $NORM]"

        fi

	#Check Battery Level
        BBU_OK=$(sudo $MEGAPATH AdpBbuCmd -GetBbuStatus -aALL | grep '^isSOHGood' |awk {'print $2'})
        if [ "$BBU_OK" == "Yes" ];then
                BBU_OK=$(sudo $MEGAPATH -AdpBbuCmd -GetBbuStatus -aALL | awk '$0~/Relative State of Charge/ {print $(NF-1)}')
                if [ "$BBU_OK" -ge 80 ]; then
	                echo -e "Controller Battery Status:\t $BBU_OK% Charged\t\t [$GREEN PASSED $NORM]"
                else
                        echo -e "Controller Battery Status:\t $BBU_OK% Charged\t\t [$RED  LOW   $NORM]"
                fi
        else

                echo -e "Current Disk Cache Policy: \t Bad Battery\t\t [$RED FAILED $NORM]"

        fi

	echo

else

	echo -e "$RED [ERROR] $NORM could not locate MegaCli utility on this server, see documentation."

fi

echo
echo "  For more information and full documentation on how to handle RAID problems,"
echo "please see the Wiki article [[Raid_Controller_Monitoring_and_Emergency_Response]]"
echo

Zerion Mini Shell 1.0