软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" | grep -i state | awk '{print $NF}')
# Check if the array is in a degraded state
if [[ "$STATUS" != "clean" ]]; then
echo "WARNING: Array $ARRAY is in a degraded state! Status: $STATUS"
else
echo "INFO: Array $ARRAY is in a clean state."
fi
[root@103 ~]# cat a.sh
#!/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" | grep -i state | awk '{print $NF}')
# Check if the array is in a degraded state
if [[ "$STATUS" != "clean" ]]; then
echo "WARNING: Array $ARRAY is in a degraded state! Status: $STATUS"
else
echo "INFO: Array $ARRAY is in a clean state."
fi
none