amuck-landowner

LSI MegaRAID Email Alerts

XFS_Brian

New Member
Verified Provider
This guide shows you how to set up email alerts for your LSI MegaRaid card. The email script used in this guide will only send you an email if one of two things have happened to the Raid. If the array is Degraded or a Drive has failed.

 

This guide assumes that you have already installed the MegaCli onto the server.

 

To start, the server needs to have either postfix or sendmail installed. Along with either of these, you also need to install mailx. To check to see if have postfix or sendmail installed, run the commands listed below:



ls /etc/init.d | grep postfix
ls /etc/init.d | grep sendmail

 

If either of these output postfix or sendmail, then you are set. If it does not, then you need to install one of them:


Code:
yum install postfix -y
yum install sendmail -y
Now to make sure that they will start when the server is rebooted, we need to run:



chkconfig postfix on
chkconfig sendmail on
Before we start the service, we need to install mailx.



yum install mailx -y
Now we start the mail service.



service postfix start
service sendmail start
The raid check is done using a cron job. You can set the cron job to run how you like, but for the purpose of this guide, we are going to set it to check hourly.



cd /etc/cron.hourly
Once you are in the folder, user your favorite editor to create a new file called MegaRAIDcron. For the purpose of this guide, we are going to use nano.



nano MegaRAIDcron
In this file, we are going to place the following. Be sure to replace <REPLACE WITH EMAIL> with the email address that the alerts will be sent to.



#!/bin/bash
cd /opt/MegaRAID/MegaCli
./MegaCli64 -AdpAllInfo -aALL | grep "Degraded" > degraded.txt
./MegaCli64 -AdpAllInfo -aALL | grep "Failed" >> degraded.txt
cat degraded.txt | grep "1" > /dev/null
if [[ $? -eq 0 ]];
then
cat degraded.txt | mailx -s 'Degraded RAID on '$HOSTNAME <REPLACE WITH EMAIL>
fi
Save the changes to the file. Once the changes are made to the file, we need to assign execute permissions to the file.



chmod +x MegaRAIDcron
To test cron, we need to make one small change to the file. Change the following:

 

From

cat degraded.txt | grep "1" > /dev/null
To 

Code:
cat degraded.txt | grep "0" > /dev/null
Save the changes and run the cron manually:



/etc/cron.hourly/MegaRAIDcron
If you have installed everything correctly, you should receive an email which shows the following:

 

  Degraded        : 0

Security Key Failed              : No

  Failed Disks    : 0

Deny Force Failed                       : No

 

To change the cron from testing back to production use, change the 0 back to a 1 and you are set.

 

Again, the cron job will only send you an email if the array is degraded or a disk has failed. No news is good news.
 
Last edited by a moderator:
Top
amuck-landowner