How to set up MegaRAID email alerts under Linux?
9,039
Solution 1
Create script like:
#!/bin/bash
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 [email protected]
fi
and add it to your crontab: https://help.ubuntu.com/community/CronHowto
You also need valid sendmail program on your system, simplest config via ssmtp will be enough thou.
Solution 2
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.
Related videos on Youtube
Author by
Henno
Updated on September 18, 2022Comments
-
Henno almost 2 years
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?
-
Henno about 13 yearsNice. Do you recommend anything else to grep for, besides degraded/failed disk count?
-
Henno about 13 yearsLike warnings from log. How to get them?
-
Henno about 13 yearsAlso, 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 about 13 yearsPostfix. I got it working properly by removing "-e".
-
vatsug about 13 yearsthat is weird as coreutils' echo have -e option which enables interpretation of
\n
and other escape characters:$ echo -e "\n\n\n"
will give 4 empty lines but$ echo "\n\n\n"
will give"\n\n\n"
string as output. Maybe your shell has different version of echo, should have used/bin/bash
hashbang, fixing now...