

The following script allows to check the satus of an md device, and therefore to know if a disc from a raid is faulty. It is done by storing the result of
cat /proc/mdstat the first time the script is called, then by comparing it to the current output on following calls.
#!/bin/sh
#
# RAID monitor
#
BASE_FILE=/etc/mdstat.ok
DIFF_FILE=/tmp/mddiff$$.out
#
# make the comparison template
#
if [ ! -s ${BASE_FILE} ]
then
if [ "0" != "`id -u`" ]
then
echo "Must be 'root' to run this script for the first time!"
exit 0
fi
cat /proc/mdstat >${BASE_FILE}
fi
#
# compare current mdstat with saved good version
#
diff -C1 ${BASE_FILE} /proc/mdstat >${DIFF_FILE}
if [ -s ${DIFF_FILE} ]
then
rm -f ${DIFF_FILE}
echo "Raid problem ??"
exit 1
fi
rm -f ${DIFF_FILE}
echo "Raid OK"
exit 0
Recent comments
2 days 23 hours ago
8 weeks 4 days ago
9 weeks 3 days ago
10 weeks 2 days ago
11 weeks 3 days ago
11 weeks 3 days ago
12 weeks 3 days ago
14 weeks 1 day ago
14 weeks 5 days ago
15 weeks 5 days ago