[Mon-commit] mon/mon.d raid.monitor,NONE,1.1
Brought to you by:
trockij
From: Augie S. <as...@us...> - 2008-11-14 22:17:00
|
Update of /cvsroot/mon/mon/mon.d In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv25390 Added Files: raid.monitor Log Message: Adding raid.monitor the unified software/hardware RAID monitor. --- NEW FILE: raid.monitor --- #!/usr/bin/perl # raid.monitor # A unified RAID monitor to monitor both software and hardware RAID. # Works with Linux software RAID, 3ware's tw_cli tool, and Areca's areca_cli tool. # Augie Schwer <au...@co...> use strict; use warnings; my $MDSTAT= '/proc/mdstat'; my $TWCLI = `which tw_cli 2> /dev/null`; my $ARCCLI= `which areca_cli 2> /dev/null`; chomp $TWCLI; chomp $ARCCLI; my $mdstat = ''; # Check for any failed software RAID. if ( -f $MDSTAT ) { $mdstat = `egrep "\[.*_.*\]" $MDSTAT`; $mdstat = '' if $mdstat =~ 'read_ahead not set'; # Fix for Red Hat 7.3 boxes. } if ( $mdstat ) { print "Failure of one or more software RAID devices\n"; exit 1; } # Check for any 3ware RAID failures. if ( -x $TWCLI ) { my %controllers = (); # Handle multiple controllers. my @controllers = `$TWCLI info | grep '^c' | awk {'print \$1'}`; my (@units,@ports); # Iterate through controllers and find broken ports and units. for my $controller (@controllers) { chomp $controller; @{$controllers{$controller}->{'failed_units'}} = `$TWCLI info $controller | grep -v 'NOT-PRESENT' | grep '^u' | awk {'print \$3'} | grep -v 'OK' | grep -v 'VERIFYING'`; @{$controllers{$controller}->{'failed_ports'}} = `$TWCLI info $controller | grep -v 'NOT-PRESENT' | grep '^p' | awk {'print \$2'} | grep -v 'OK' | grep -v 'VERIFYING'`; } # Display failure and exit with an error if there are any failed ports or units. for my $controller (@controllers) { if ( @{$controllers{$controller}->{'failed_units'}} or @{$controllers{$controller}->{'failed_ports'}} ) { print "Failure of one or more of the hardware RAID devices.\n"; exit 1; } } } # Check for any Areca RAID failures. if ( -x $ARCCLI ) { my @failed_raid_sets = `$ARCCLI rsf info | grep 'Raid Set' | grep -v 'Normal'`; # Display failure and exit with an error if there were any failed Raid Sets. if ( @failed_raid_sets ) { print "Failure of one or more of the hardware RAID devices.\n"; exit 1; } } # Otherwise everything was OK. print "Success\n"; exit 0; |