Send e-mail when RAID fails on HP Proliant running Linux

This topic is to discuss the following lesson:

https://networklessons.com/uncategorized/send-e-mail-when-raid-fails-on-hp-proliant-running-linux/

I found this post really useful, with a few small modifications I am rolling it out to all my servers. Will also be writing one to email on content of IML as read by hplog, another essential HP utility to monitor your server health so as not to get surprised!

#!/bin/bash

# Server Health script
# Verifies Server health by querying IML and ACU
# and emails if a disk has failed or Caution/Critical message
# is found in Server Event Log (IML)
#
# Requires hp-health and hpacucli rpms to be installed
#################################################

# Global variables
ME=$0
MAILWHO=user@domain
HPACUCLI=<code>which hpacucli</code>
HPLOG=<code>which hplog</code>
HPACUCLI_TMP=/tmp/hpacucli.log
HPLOG_TMP=/tmp/hplog.log


# Code to check for RPMS will go  here


# Code to check for running hp-health service will go  here

## ARRAY CHECK

SLOT=$(hpacucli controller all show | grep Smart | awk '{print $6}')
$HPACUCLI controller slot=$SLOT physicaldrive all show &gt; $HPACUCLI_TMP

if [ <code>cat $HPACUCLI_TMP | grep physicaldrive | grep -v OK | wc -l</code> -gt 0 ]
then
        SUBJECT="RAID Controller Errors"
        logger -p syslog.error -t $ME "$SUBJECT found. Please check Array status using hpacucli"
        mail -s "$HOSTNAME: $SUBJECT" "$MAILWHO"  $HPLOG_TMP
# Section to be written, will look for Caution and Critical messages only

Saw that my code got messed up above while posted, some missing characters so not cut and pastable!

Hi Matt,

Thanks for sharing this! I’ll try it the next time I’m installing a proliant server.

Rene