#!/bin/bash
#
# raidstatus.sh - Gene Cooper <gcooper@sonoracomm.com>
# 
# For LSI RAID controllers
# 
# Uses megarc utility and should be run from cron
#

# Subject of e-mail warning
SUBJECT='RAID Array Failure on Server'

# Recipient of e-mail warnings
ADMIN='admin@yourdomain.com'

# Directory containing megarc utility
MEGARC='/root/megarc'

# dump hardware failure info to a text file
cd ${MEGARC}
nice -n 19 ${MEGARC}/megarc -pdfailinfo -a0 -chall -idall > ${MEGARC}/pdfailinfo.txt

# look for an error message
FAILURE=`nice -n 19 grep "No Error Information" ${MEGARC}/pdfailinfo.txt | wc -l`

# if no failure, exit
if [ ${FAILURE} == 1 ]
then
  exit
else
  mail -s "${SUBJECT}" $ADMIN < ${MEGARC}/pdfailinfo.txt
fi 
exit

