File: //bigscoots/dedicated/raid_manager.sh
#!/bin/bash
if lspci | grep -iq 'megaraid\|lsi\|broadcom'; then
echo "✅ MegaRAID controller detected. Proceeding with StorCLI setup."
# Safe working directory
cd /tmp
wget -O storcli.zip "https://www.dropbox.com/scl/fi/hqltapekkmssy9xqy60t7/007.3205.0000.0000_MR7.32_Storcli.zip?rlkey=juv9d6g19wkuiykbfzebvvvag&dl=0"
unzip -o storcli.zip
unzip -o storcli_rel/Unified_storcli_all_os.zip
rpm -ivh "Unified_storcli_all_os/Linux/storcli-007.3205.0000.0000-1.noarch.rpm" || \
rpm -Uvh "Unified_storcli_all_os/Linux/storcli-007.3205.0000.0000-1.noarch.rpm"
ln -sf /opt/MegaRAID/storcli/storcli64 /bin/storcli64
storcli64 -v
# Load Slack function
source /bigscoots/includes/common.sh
controller="/c0"
output=$(storcli64 $controller /eall /sall show)
# Grab the PD list block
start_line=$(echo "$output" | grep -n "^EID:Slt" | cut -d: -f1)
end_line=$(echo "$output" | grep -n "^EID=Enclosure Device ID" | cut -d: -f1)
((end_line--)) # Adjust for clean end
pd_list=$(echo "$output" | sed -n "${start_line},${end_line}p")
# Look for drive problems
problem_lines=$(echo "$pd_list" | grep -E 'Failed|Offln|Msng|UBad|Uncfg' || true)
message="*RAID Physical Drive List:*\n\`\`\`$pd_list\`\`\`"
if [[ -n "$problem_lines" ]]; then
send_slack_alert "#test" ":rotating_light:" "RAID Alert" "$(hostname -f)" "$message"
else
echo "✅ All drives healthy. No alert sent."
fi
else
echo "❌ No MegaRAID controller found. Skipping StorCLI install."
fi