Flying blind is no fun and many hardware manufacturers are notoriously bad at providing info tools form their hardware for Linux. If you have an LSI-chipped RAID controller, this may come in handy. The `storcli`utility replaces the MegaCLI utility and is provided by Broadcom.
You can get `storcli`here:
docs.broadcom.com/docs/007.1506.0000.0000_Unified_StorCLI-PUL.zip
(For Debian/Ubuntu distributions, you may need to install `alien` to convert the .rpm to .deb.)
The following script is what I use and it works for me:
#!/bin/bash
#
# Check LSI RAID storage status
#
# This will trigger on the output NOT being "Optl" (Optimal). This works for me,
# your mileage may vary. One problem in using more "verbose output" from the
# storcli64 binary is that it always (?) outputs some sort of legend with all
# the various status types explained, so it always contains the text "Degraded"
# for example. This minor script will simply search for what we want, which is
# a RAID in optimal state, and if NOT found, perform a full status scan and send
# it as an e-mail message to wherever it needs to be sent.
#
# Joaquim Homrighausen <joho@webbplatsen.se>
# 2020-12-15
#
STATUS=`/usr/local/bin/storcli64 /c0 /v0 show nolog |egrep "RAID6 Optl"`;
EGREP=$?
if [ "$EGREP" -ne 0 ]
then
TO=my.email@address.ext
STATUS=`/usr/local/bin/storcli64 /c0 show`;
/usr/sbin/sendmail -i $TO <<MAIL_END
From: root@my.monitored.server
To: $TO
Subject: RAID WARNING @ `hostname`
$STATUS
MAIL_END
fi