--- /dev/null
+# 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;