软RAID监控脚本
#!/bin/bash
# Define the array device
ARRAY="/dev/md10"
# Check if the array is active
if ! mdadm --detail "$ARRAY" >/dev/null 2>&1; then
echo "ERROR: Array $ARRAY is not active or does not exist."
exit 1
fi
# Check the array status
STATUS=$(mdadm --detail "$ARRAY" | awk -F': ' '/State/ {print $2}' | tr -d '[:space:]')
if [[ "$STATUS" =~ (degraded|recovering|resyncing|inactive) ]]; then
echo "⚠️ WARNING: Array $ARRAY is in a problematic state! -> $STATUS"
exit 2
elif [[ "$STATUS" =~ (clean|active) ]]; then
echo "✅ INFO: Array $ARRAY is healthy ($STATUS)"
exit 0
else
echo "❓ UNKNOWN: Unable to determine RAID state ($STATUS)"
exit 3
fi
none



