RAID monitoring with StorCLI

In this article, we'll show you how to monitor your RAID controller in Linux with StorCLI, so that you know when a faulty disk needs to be replaced.


StorCLI is a tool from Broadcom for monitoring and querying MegaRAID controller cards. Using this tool, you can view the RAID controller status on your dedicated server and be alerted if a disk is failing and needs replacement.

Installing the tools

Start by downloading StorCLI from Broadcom's website (https://docs.broadcom.com/docs/1232743397). Unfortunately, you cannot download this directly using wget. You'll need to download it via a web browser and then transfer it to your server using scp or WinSCP.

Once you have transferred the zip file to your server, you'll need to unpack it twice—there's a zip file inside the zip file:

Multiple commands
unzip 007.2705.0000.0000_storcli_rel.zip
cd storcli_rel
unzip Unified_storcli_all_os.zip

Next, you need to install the package. Broadcom only provides an RPM file, so depending on which Linux distribution you are using, you need to convert the package first. If you are using Fedora, AlmaLinux, or CentOS, no conversion is needed.

If the server is running Fedora or AlmaLinux, you can go ahead and install the package:

Multiple commands
cd Unified_storcli_all_os/Linux
sudo dnf install ./storcli-007.2705.0000.0000-1.noarch.rpm

Once the installation is complete, move the binary storcli64 to /usr/local/bin/.

Command
sudo mv /opt/MegaRAID/storcli/storcli64 /usr/local/bin/

You'll also need jq to automate the monitoring of the RAID controller. Install the package as shown below, depending on your distribution.

Command
sudo dnf install jq

Quering the RAID controller

In the above command, c0 indicates which controller you're checking; it's usually 0 if you only have one.

Before creating the monitoring script, you can check the status of your RAID controller using the following command. If everything is fine, it should return "Optimal". If something is wrong, it returns "Needs attention".

Automating the monitoring

The script below will send you an email if the status is not "Optimal".

For the script to work, you'll need a fully working SMTP server installed, such as Postfix. See the article Sending email from your server using Postfix for information on how to set up your own Postfix server.

Next, create a file called raidcheck.sh in a directory of your choice and edit the file with vim or nano. Paste the following code:

You need to change the FROM_EMAIL and TO_EMAIL variables at the beginning of the script to match your email address and the sender's email address.

You also need to make raidcheck.sh executable:

Next, you'll need to add the script to root's crontab (since storcli64 requires root permissions to access the controller). You can open root's crontab either by using sudo crontab -e, or by first switching to root with su, and then running crontab -e.

Once root's crontab is open, paste the following line. Change the path to where your script is located. This crontab will run the script 10 minutes past every hour. For more information about crontab, see Automate tasks in Linux using cron.

Notes

We recommend that you test the script to ensure that it truly works before putting it into live operation. The script is designed to fit most distributions, but there's no guarantee it will suit your specific server.

Last updated

Was this helpful?