mdadm/raid-check
Doug Ledford bb4afe8c1c - Improved raid-check script as well as the ability to configure what
devices get checked
- Endian patch for uuid generation
2009-07-24 17:43:39 +00:00

59 lines
1.5 KiB
Bash

#!/bin/bash
#
# This script reads it's configuration from /etc/sysconfig/raid-check
# Please use that file to enable/disable this script or to set the
# type of check you wish performed.
[ -f /etc/sysconfig/raid-check ] || exit 0
. /etc/sysconfig/raid-check
[ "$ENABLED" != "yes" ] && exit 0
case "$CHECK" in
check) ;;
repair) ;;
*) exit 0;;
esac
dev_list=""
for dev in `grep "^md.*: active" /proc/mdstat | cut -f 1 -d ' '`; do
echo $SKIP_DEVS | grep -w $dev >/dev/null 2>&1 && continue
if [ -f /sys/block/$dev/md/sync_action ]; then
array_state=`cat /sys/block/$dev/md/array_state`
sync_action=`cat /sys/block/$dev/md/sync_action`
# Only perform the checks on idle, healthy arrays
if [ "$array_state" = "clean" -a "$sync_action" = "idle" ]; then
check=""
echo $REPAIR_DEVS | grep -w $dev >/dev/null 2>&1 && \
check="repair"
echo $CHECK_DEVS | grep -w $dev >/dev/null 2>&1 \
&& check="check"
[ -z "$check" ] && check=$CHECK
echo "$check" > /sys/block/$dev/md/sync_action
[ "$check" = "check" ] && dev_list="$dev_list $dev"
fi
fi
done
if [ -n "$dev_list" ]; then
checking=1
while [ $checking -ne 0 ]
do
sleep 3
checking=0
for dev in $dev_list; do
sync_action=`cat /sys/block/$dev/md/sync_action`
if [ "$sync_action" != "idle" ]; then
checking=1
fi
done
done
for dev in $dev_list; do
mismatch_cnt=`cat /sys/block/$dev/md/mismatch_cnt`
if [ "$mismatch_cnt" -ne 0 ]; then
echo "WARNING: mismatch_cnt is not 0 on /dev/$dev"
fi
done
fi