> From: Theo Van Dinter > Just curious-- > > has anyone written a generic "monitor" script that checks the status of the > RAID arrays currently in use? something that might mail if there's an error > ? > > I started working on one, but don't want to reinvent the wheel. I just wrote the enclosed. I'll use 0 * * * * /etc/raid.d/mdmon steve
#!/usr/bin/perl # if ( ! -f "/proc/mdstat" ) { print "no /proc/mdstat (kernel doesn't have md support?)\n"; exit 1; } open(IN,"</proc/mdstat"); while (<IN>) { if ( $_ =~ /\s+active\s+/ ) { $_ =~ /\[(\d+)\/(\d+)\]/; $count = $1; $active = $2; if ( "$active" ne "$count" ) { @F = split(/\s+/); print "Warning: /dev/$F[0] has a dead partition!\n"; print "$_"; } } }