Thursday, May 8, 2008

Script to send email alerts from Perc 5/i on PowerEdge running CentOS 5.1

Updated: 2008-05-15: see below

Need to get an alert if one of the hard drives fail on my PowerEdge 1900 running CentOS 5.1 and Dell's OMSA.

Nagios and ITA seem a little hard to swallow...would like something simple. Some links below talk about this issue with the Perc 5/i.

Discussion on MegaRAID_SAS driver on PowerEdge

Discussion on Perc 5/i inaudible alarm and possible script to use with omreport

Another possible to use to supplement alerts...but probably not storage

Ok. End result. Spent a lot time on the script in comments section of the link above. Couldn't get it to work. Bash didn't like the pipe command in the strings. So I brushed up on my VERY minimal perl skills and created the following to run in cron daily:


# A simple perl program to send alerts if problem found with physical disks
# by using OMSA 5.2 for Dell PowerEdge
# I do not provide any guarantee that this script will work. Use at own risk.

#Written: May 2008
#By: Jerod Hammerstein


# run omreport command and put into olist

open(LS, "$omreport storage pdisk controller=$controller |");
while() {
push @olist, $_;

# Go through each line in olist to look for "Critical", "Rebuilding", or
# "Failure Predicted : YES"


foreach $line(@olist){
if ($line =~ /Critical$/i) {
$subject="$servername Hard Drive Critical";
if ($line =~ /Failure$/i) {
$subject="$servername Hard Drive Rebuilding";
if ($line =~ /^Failure\sPredicted(\s)+:\sYes$/i) {
$subject="$servername Hard Drive Predicted to Fail";

#If something was found email will = 1 so send email
if ($email==1) {
system("$omreport storage pdisk controller=$controller | $mail -s '$subject' $emailaddress");


Ran as root

crontab -e

Then put

0 8 * * * /root/

in the crontab file.

I'm sure I could have done a better job in the regular expressions (and probably in most of the code), but it's simple and it works. Most of all I think it is very understandable compared to many perl scripts I've seen.

Feel free to use and alter... You will need sendmail can keep port 25 blocked on your external interface in your firewall as it uses the lo interface. No guarantees it will work for you though.

The dell poweredge list serv had a message that someone uses to have it alert of disk problems:

omconfig system alertaction event=pdiskwarn execappath="(script
to send email)"

I tried this on my Dell PowerEdge 1900 using a simple perl script in the execappath that works otherwise and I got

Error! Hardware subsystem reports command failed.

1 comment:

Stijn van der Ree said...

You got:

"Error! Hardware subsystem reports command failed."

Did your filename have a dot in it? Removing it did the trick for me.