In this article, we'll show you how to easily monitor your RAID in Linux with storcli so you know when a faulty disk needs to be replaced.
storcli64 /c0 show all
(c0 indicates which controller you're checking, it's usually 0 if you only have one)
In the script below we check for controller status and if its "optimal" or "needs attention".
If the controller has status "needs attention" you have to investigate further with above command to find out whats the issue.
Things you need:
Start by downloading and unpacking StorCLI from the Broadcom 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.
Install needed packages
apt-get update
apt-get install alien jq
alien storcli-007.2705.0000.0000-1.noarch.rpm
dpkg -i storcli_007.2705.0000.0000-2_all.deb
mv /opt/MegaRAID/storcli/storcli64 /usr/local/bin/
#!/bin/bash
FROM_EMAIL="from@example.com"
TO_EMAIL="to@example.com"
SUBJECT="Controller Status Alert"
send_email() {
local subject="$1"
local body="$2"
{
echo "Subject: $subject"
echo "To: $TO_EMAIL"
echo "From: $FROM_EMAIL"
echo "MIME-Version: 1.0"
echo "Content-Type: text/plain; charset=UTF-8"
echo ""
echo "$body"
} | sendmail -t -f "$FROM_EMAIL"
}
status_json=$(storcli64 /call show all j)
controller_status=$(echo "$status_json" | jq -r '.Controllers[0]."Response Data".Status."Controller Status"')
echo "Current Controller Status: $controller_status"
if [[ "$controller_status" != "Optimal" ]]; then
message="Warning: The controller status is not Optimal.\n\nCurrent Status: $controller_status\n\nDetails:\n$status_json"
send_email "$SUBJECT" "$message"
echo "Email notification sent about the controller's non-optimal status."
else
echo "------------------------------------"
echo "Controller status is Optimal."
fi
You need to change the "from" and "to" email addresses at the beginning of the script.
chmod +x raidcheck.sh
10 * * * * /path/to/your/script/raidcheck.sh
We recommend that you test the script to ensure 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.
Kontakta oss gärna för mer information. Vi hjälper dig att komma fram till den bästa lösningen för dina behov.