Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Ubuntu 10.04 and MegaRAID controller. The only tool I have is the notorious MegaCli. I need to be emailed when some disk has failed in the RAID array. How to set that up?

share|improve this question

migrated from Apr 26 '11 at 17:11

This question came from our site for system and network administrators.

up vote 2 down vote accepted

Create script like:

STATUS=`MegaCli -AdpAllInfo -aALL -NoLog|egrep '^  (Degraded|Failed)'|grep -v ' 0'`;

if [ "x$STATUS" != "x" ]; then
  echo -e "Subject: RAID WARNING @ `hostname`\n\n$STATUS"|/usr/sbin/sendmail

and add it to your crontab:

You also need valid sendmail program on your system, simplest config via ssmtp will be enough thou.

share|improve this answer
Nice. Do you recommend anything else to grep for, besides degraded/failed disk count? – Henno Apr 26 '11 at 21:59
Like warnings from log. How to get them? – Henno Apr 26 '11 at 22:02
Also, there seems to be a slight problem with the echo command. I get subjectless email with a body of "-e Subject: RAID WARNING @ myhostname" – Henno Apr 26 '11 at 22:13
what provides your /usr/sbin/sendmail command? – romke Apr 26 '11 at 22:16
Postfix. I got it working properly by removing "-e". – Henno Apr 27 '11 at 7:08

You can get the MegaRAID Storage Manager from LSI, and it can be setup to email you on RAID events (amongst other things, like SNMP).

There's no speicifc Ubuntu version of it, but LSI provides a knowledge base article that explains how to get the "Linux" version working; hopfully it'll work for you, or at least get you going.

share|improve this answer

I think the Nagios plugin check_raid speaks megacli. You could use it standalone to write your own script. Like all Nagios plugins, it gives you an exit code of 1 if it thinks something is wrong. A cron entry like

sh -c "check_raid > /tmp/raid_status || cat /tmp/raid_status"

should give you a very basic solution.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .