Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


LSI MegaRAID Email Alerts
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

LSI MegaRAID Email Alerts

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:


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 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

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.

Comments

  • Not bad, although I wouldn't recommend installing an MTA just to send raid alerts. Use smtp-cli instead.

    Thanked by 1torrbox
  • twaintwain Member

    If debian/Ubuntu, there are lsi tools provided by this repo that will email raid alerts:

    http://hwraid.le-vert.net/wiki/DebianPackages

  • smansman Member
    edited July 2013

    Thanks for this procedure. Sendmail and mailx were already installed and enabled by default on a Solus node so all I had to do was add the cron.

    I always thought I had something like this configured already via the MegaRAID Storage Manager but I guess I didn't. I also have logwatch email me daily logs but not sure if I would see anything that way either. These rare type disasters are always the ones that bite you so I'm always on the lookout for this sort of info.

  • @sman said:
    Thanks for this procedure. Sendmail and mailx were already installed and enabled by default on a Solus node so all I had to do was add the cron.

    I always thought I had something like this configured already via the MegaRAID Storage Manager but I guess I didn't. I also have logwatch email me daily logs but not sure if I would see anything that way either. These rare type disasters are always the ones that bite you so I'm always on the lookout for this sort of info.

    Glad to hear that this helped.

  • I know this article is really old, However its the only good one I can find. I followed the steps and everything works when I issue the test command. The problem is when I make the array fail it will not send an email.
    Using Centos 7 and LSI 9260-8i
    Any help would be Appreciated or maybe a tutorial on the StorCli ?

  • jarjar Patron Provider, Top Host, Veteran

    @Antairus said:
    I know this article is really old, However its the only good one I can find. I followed the steps and everything works when I issue the test command. The problem is when I make the array fail it will not send an email.
    Using Centos 7 and LSI 9260-8i
    Any help would be Appreciated or maybe a tutorial on the StorCli ?

    Check your postfix logs (often /var/log/mail.log) and see if the mail is just not sending at all, or if it's being rejected. You still need to do the things necessary to make the server into a decent mail server if sending to a recipient server with any decent protections. Things like valid FQDN hostname, PTR, fcrdns, etc.

  • With all do respect to OP, I'd recomend following changes to that script:

    1. put the whole output of storcli/megacli command to that file

    2. change if condition to check file content for strings degraded/failed

    3. send mail with the whole file content in message body

  • Another alternative worth exploring in my opinion are the various log collection/management SaaS services, such as Logentries or Papertrail: forwarding the log messages to one of those services allows for more notification options than just email (SMS, Slack, etc.) and even if you configure an email notification their deliverability is likely to be much better than your own server's.

    I've used Logentries at work and Papertrail for my own servers, but the one I'm happily using today is LogDNA: their cheapest plan is a steal at $1.25 per month and they've always responded quickly to my bug reports or suggestions.

  • Its not that I don't get the emails. when I send a test to a couple of addresses it works.
    The problem seems to be that its not triggering the event when I degrade the array. IE pulling a drive.

  • jarjar Patron Provider, Top Host, Veteran
    edited September 2017

    @Antairus said:
    Its not that I don't get the emails. when I send a test to a couple of addresses it works.
    The problem seems to be that its not triggering the event when I degrade the array. IE pulling a drive.

    Does this generate any data in such a case?

    cd /opt/MegaRAID/MegaCli
    ./MegaCli64 -AdpAllInfo -aALL | grep "Degraded"

  • @jarland said:

    @Antairus said:
    Its not that I don't get the emails. when I send a test to a couple of addresses it works.
    The problem seems to be that its not triggering the event when I degrade the array. IE pulling a drive.

    Does this generate any data in such a case?

    cd /opt/MegaRAID/MegaCli
    ./MegaCli64 -AdpAllInfo -aALL | grep "Degraded"

    I get
    Degraded :2

  • jarjar Patron Provider, Top Host, Veteran

    Antairus said: I get Degraded :2

    I'd assume at this stage that the script is working. It's only executing every hour though. At the risk of a dumb question, are you making sure that this is the state at the top of the hour?

  • @jarland said:

    Antairus said: I get Degraded :2

    I'd assume at this stage that the script is working. It's only executing every hour though. At the risk of a dumb question, are you making sure that this is the state at the top of the hour?

    I have had the drive unplugged for 3 Hours. In my mail log it only shows the Test mail.
    I reset the integer back to 1 like the Tutorial said as well.

  • jarjar Patron Provider, Top Host, Veteran

    Antairus said: I have had the drive unplugged for 3 Hours. In my mail log it only shows the Test mail. I reset the integer back to 1 like the Tutorial said as well.

    Yeah you got me. Sounds like either a logic error with the rest of the script or the cron isn't running. Seems like the only two likely scenarios.

  • @jarland said:

    Antairus said: I have had the drive unplugged for 3 Hours. In my mail log it only shows the Test mail. I reset the integer back to 1 like the Tutorial said as well.

    Yeah you got me. Sounds like either a logic error with the rest of the script or the cron isn't running. Seems like the only two likely scenarios.

    Yeah I think its the cron. Thanks for the help though.

  • I can't run it , it show :
    /etc/cron.hourly/MegaRAIDcron: line 2: cd: /opt/MegaRAID/MegaCLi: No such file o r directory
    /etc/cron.hourly/MegaRAIDcron: line 3: ./MegaCli64: No such file or directory
    /etc/cron.hourly/MegaRAIDcron: line 4: ./MegaCli64: No such file or directory
    help me !!

  • Apparently you do not have megacli installed. So run to lsi/avago/broadcom/wtf web, grab one and install it!

    BTW, MegaCLI is not developed anymore, new version is called StorCLI (has different syntax, so you will have to modify that script)...

  • Lots of luck when you can't even find it..

  • ClouviderClouvider Member, Patron Provider

    Well, I guess you should start with resolving the errors it throws at you before posting here.

  • KuJoeKuJoe Member, Host Rep

    Yes, let's reply to a thread from 2013 before bothering to install the software required...

  • Thanks for digging this up. Very relevant to my interests.

Sign In or Register to comment.