it-artikel:lsi-megaraid-automatische-ueberwachung-des-raid-status-und-der-festplatten-per-script

LSI MegaRaid - Automatische Überwachung des RAID Status und der Festplatten per Script

Es gibt zur Zeit keine vernünftige Hersteller-Lösung für dieses Problem. Daher habe ich ein eigenes Script hierfür entwickelt. — Axel Werner 2009-04-08 17:13

Requirements / Vorraussetzungen

Installation

  1. Alle nachfolgend gezeigten Files und Scripte nach /etc kopieren.
  2. Das *.sh Shellscript ausführbar machen
  3. Den Aufruf für das Shellscript in /etc/crontab einfügen. z.B.
#RAID System Zustandsueberwachung alle 30 Minuten
*/30 * * * *	root	/etc/raid-checker.sh

Scripte / Files

raid-checker.sh

#!/bin/bash
#
# LSI MegaRaid HEALTH CHECK v.1.00 - 2009-04-06 - Axel Werner [mail@awerner.myhome-server.de]
#
# Call this script on a regulary basis like in /etc/crontab or similar.
# it will check the Health Status of your LSI MegaRaid RAID System and reports Problems
# by eMail (via Cron) of something had failed.
#
#
# This script requires the two AWK Scripts raid-checker1.awk and raid-checker2.awk
#
 
 
# preset Vars to signal a FAILURE of the RAID System.
PDSTATUS=FALSE
LDSTATUS=FALSE
NUMSTATUS=FALSE
 
cd /etc
 
if ! MegaCLI64 -PDList -aALL | awk -f raid-checker1.awk | grep -qEv '*: Online' > /dev/null ; then
	# no Problem found - set flag that everything is OK
	PDSTATUS=TRUE
fi
 
 
if ! MegaCLI64 -LDInfo -LALL -aAll | awk -f raid-checker2.awk | grep -qEv '*: Optimal' > /dev/null ; then
	# no Problem found - set flag that everything is OK
	LDSTATUS=TRUE
fi
 
PDSOLL=`MegaCLI64 -LDInfo -LALL -aAll | grep '^Number Of Drives:' | cut -f2 -d':'`
PDIST=`MegaCLI64 -PDList -aALL | grep '^Firmware state:' | wc -l`
if [ ${PDSOLL} -eq ${PDIST} ] ; then
	# no Problem found - set flag that everything is OK
	NUMSTATUS=TRUE
fi
 
 
if [ ${PDSTATUS} = FALSE -o ${LDSTATUS} = FALSE -o ${NUMSTATUS} = FALSE ] ; then
	# Problem Found - Report Flags
	echo 'RAID @ '"${HOSTNAME}"' - WARNING: RAID SYSTEM IS NO LONGER OPTIMAL! CHECK THE HARDWARE!'
	echo
	echo 'Logical Drives OK?  = '${LDSTATUS}
	echo 'Physical Drives OK? = '${PDSTATUS}
	echo 'All PDs available?  = '${NUMSTATUS}
	echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
	echo
	echo 'Logical Drives View'
	echo '###################'
	MegaCLI64 -LDInfo -LALL -aAll
	echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
	echo
	echo 'Physical Drives View'
	echo '####################'
	echo
	MegaCLI64 -PDList -aALL
	echo
	echo
	echo '~~~ END OF REPORT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
fi

raid-checker1.awk

#
# This file is Part of the raid-checker scripts
#
# This is a little AWK program that interprets MegaCLI output
# This one interprets the PHYSICAL DRIVES
 
    /Device Id/ { counter += 1; device[counter] = $3 }
    /Firmware state/ { state_drive[counter] = $3 }
    /Inquiry/ { name_drive[counter] = $3 " " $4 " " $5 " " $6 }
    END {
    for (i=1; i<=counter; i+=1) printf ( "Device %02d (%s) status is: %s <br/>\n", device[i], name_drive[i], state_drive[i]); }

raid-checker2.awk

#
# This file is Part of the raid-checker scripts
#
# This is a little AWK program that interprets MegaCLI output
# This one interprets the LOGICAL DRIVES
 
    /Virtual Disk/ { counter += 1; device[counter] = $3 }
    /State/ { state_drive[counter] = $2 }
    END {
    for (i=1; i<=counter; i+=1) printf ( "Logical Drive %02d status is: %s <br/>\n", device[i], state_drive[i]); 
	}
it-artikel/lsi-megaraid-automatische-ueberwachung-des-raid-status-und-der-festplatten-per-script.txt · Last modified: 2015-07-23 20:40 by mail@awerner.myhome-server.de