From 0a23330ca531d998e88df6ce08787f37b33ba2df Mon Sep 17 00:00:00 2001 From: Alan Premselaar Date: Fri, 30 Sep 2005 10:28:24 +0000 Subject: [PATCH] First version of a plugin to check the 3ware RAID controller Written by Alan Premselaar --- src/lib/Spong/Client/plugins/check_RAID | 82 +++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 src/lib/Spong/Client/plugins/check_RAID diff --git a/src/lib/Spong/Client/plugins/check_RAID b/src/lib/Spong/Client/plugins/check_RAID new file mode 100755 index 0000000..3882c35 --- /dev/null +++ b/src/lib/Spong/Client/plugins/check_RAID @@ -0,0 +1,82 @@ +# Register this routine with the plugin registery + +$CHECKFUNCS{'RAID'} = \&check_RAID; + + +# This routine checks the 3ware RAID system for drive or controller faults +# +# this routine will only return green or red as I don't know the status codes to check +# for currently to return yellow states (nor do i currently have a need, i can fix it later +# if necessary) + +# the absolute path for $RAID_CHECK should probably be handled better, and it's dependant on the +# 3ware software being installed. + +# $Id: check_RAID,v 1.1 2005/09/30 10:28:24 apremselaar Exp $ + +use Spong::SafeExec qw(safe_exec); + +sub check_RAID { + my $color = "green"; + my ($summary,$message); + my (@controllers, @units, @ports); + my $RAID_CHECK = "/usr/local/sbin/tw_cli info"; + my %INFO = (); + my @probs = (); + + # get controllers + my @input = safe_exec($RAID_CHECK,30); + + foreach my $line (@input) { + $message .= $line; + if ($line =~ /^Controller (\d+):/) { + push(@controllers,$1); + } + } + + $message .= "\n" if ($message); + + # get the info per contoller + + foreach $controller (@controllers) { + my $CONT_CHECK = $RAID_CHECK . " c$controller"; + + my @input = safe_exec($CONT_CHECK,30); + + foreach my $line (@input) { + $message .= $line; + if ($line !~ /^(Controller|--|#)/) { + if ($line =~ /^\s+(\w+\s*\d*):\s+(.+)/) { + $INFO{$controller}{$1} = $2; + } + } + + } + $message .= "\n" if ($message); + } + + + # let's check for OK status + + foreach my $contr (keys %INFO) { + foreach my $key (sort inverse keys %{$INFO{$contr}}) { + if ($INFO{$contr}{$key} !~ /: OK/) { + $color = "red"; + $color = "yellow" if ($INFO{$contr}{$key} =~ /: INITIALIZING/); + push(@probs, $key); + } + } + } + + $summary = "RAID system ok" if $color eq "green"; + $summary = "RAID system failure with: " . join(', ',@probs) if ($color ne "green"); + + &debug( "RAID - $color, $summary" ); + &status( $SPONGSERVER, $HOST, "RAID", $color, $summary, $message ); + + + sub inverse { $b <=> $a } +} + +# I'm include perl code, I need this line. +1; -- 2.30.2