Subject: raid status in /etc/daily
To: None <tech-userlevel@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-userlevel
Date: 01/26/2002 22:26:47
--G4iJoqBmSsgzjUCe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,
With raid device, a failed disk may stay unnoticed for long, if noone runs
a raidctl -s on the device to check the status.
The attached patch checks for failed components in raid devices, and produce
an output like this:
failed RAID component(s):
raid1:
           /dev/sd2e: failed

I've it on several of my machines, and it helped at last one time.
would anyone object if I commit it ?

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
--

--G4iJoqBmSsgzjUCe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: daily
===================================================================
RCS file: /cvsroot/basesrc/etc/daily,v
retrieving revision 1.45
diff -u -r1.45 daily
--- daily	2001/12/18 00:51:16	1.45
+++ daily	2002/01/26 21:15:09
@@ -157,9 +157,22 @@
 		fi
 		echo ""
 	fi
+	rm -f $TMP $TMP2
+	touch $TMP2
+	for dev in `iostat -x | awk '/^raid/ { print $1 }'`; do
+		raidctl -s $dev | awk '/^.*: failed$/ {print $0}' > $TMP
+		if [ -s $TMP ]; then
+			echo "$dev:" >> $TMP2
+			cat $TMP >> $TMP2
+		fi
+		rm -f $TMP
+	done
+	if [ -s $TMP2 ]; then
+		echo "failed RAID component(s):"
+			cat $TMP2
+	fi
+	rm -f $TMP2
 fi
-
-rm -f $TMP $TMP2
 
 if checkyesno check_mailq; then
 	mailq > $TMP

--G4iJoqBmSsgzjUCe--