Storcli
The storcli binary can usually be found under /opt/lsi or /opt/MegaRAID and can be obtained from the Broadcom website.
Once installed you can…
Genearal Commands
Show all settings/status
/storcli /c0 show all
Show rebuild status
storcli /c0 /eall /sall show rebuild
Create a new RAID
storcli64 /c0 add vd type=RAID6 drives=8:12-22
storcli64 /c0/v1 start init
Set a drive to be identified as good
sudo /opt/MegaRAID/storcli/storcli64 /c0/e21/s5 set good force
Set a drive to be identified as bad
sudo /opt/MegaRAID/storcli/storcli64 /c0/e21/s5 set bad force
Drive Identification Commands
Locate a drive
sudo /opt/MegaRAID/storcli/storcli64 /c0/e8/s17 start locate
Stop locating a drive
sudo /opt/MegaRAID/storcli/storcli64 /c0/e8/s17 start locate
Alarm Commands
Show alarm status
storcli /cx show alarm
Set the status of an alarm
storcli /cx set alarm=<on|off|silence>
Hot Spare Commands
Create a hot spare
sudo /opt/MegaRAID/storcli/storcli64 /c0/e21/s5 add hotsparedrive
Delete a hot hot hotsparedrive
sudo /opt/MegaRAID/storcli/storcli64 /c0/e21/s23 delete hotsparedrive
CLI Version = 007.1017.0000.0000 May 10, 2019
Operating system = Linux 3.10.0-957.21.3.el7.x86_64
Controller = 0
Status = Success
Description = Delete Hot Spare Succeeded.
Foreign Configuration Commands
Show foreign configurations
sudo /opt/MegaRAID/storcli/storcli64 /c0/fall show
Delete foreign configurations
sudo /opt/MegaRAID/storcli/storcli64 /c0/fall delete
CLI Version = 007.1017.0000.0000 May 10, 2019
Operating system = Linux 3.10.0-957.21.3.el7.x86_64
Controller = 0
Status = Success
Description = Successfully deleted foreign configuration
Monitoring with cron
Create a cron job for email alerts of failures using storcli.
#!/bin/bash
STATUS=`/opt/MegaRAID/storcli/storcli64 -AdpAllInfo -aALL -NoLog|egrep '^ (Degraded|Failed)'|grep -v ' 0'`;
if [ "x$STATUS" != "x" ]; then
echo -e "Subject: RAID WARNING @ `hostname`\n\n$STATUS"|mail -s 'RAID Warning' email@fqdn
fi
References and further reading
https://www.broadcom.com/support/download-search?pg=Storage+Adapters,+Controllers,+and+ICs&pf=RAID+Controller+Cards&pn=&pa=&po=&dk=