#!/usr/bin/perl -w # # Plugin to monitor the actual the detailed status of a RAID-Unit. # # The resulting Digramm will show all devices(HDD) who belong to a given unit, # and displays its status in numbers between 0 and 2: # 2 - best possible status - full redudancy avaible, full performance, all is pretty well. # 1=); my $unitName; if($stringArray[1] =~ m/(\w+)/) { $unitName = $1; } else { $unitName=$targetQualifier; } print "graph_title ".$unitName." Disk-Status\n"; open (my $query_statusList,$tw_cli." ".$targetQualifier." show|") or die "Could not open tw_cli, $!"; while(<$query_statusList>) { if($_ =~ /DISK/) { my @statusArray=split(' ',$_); $statusArray[5] =~ m/(\d+)/; print $statusArray[5].".label Port".$1."\n"; print $statusArray[5].".warning 0.99:\n"; print $statusArray[5].".critical 0.01:\n"; } } } else { open (my $query_statusList,$tw_cli." ".$targetQualifier." show|") or die "Could not open tw_cli, $!"; while(<$query_statusList>) { if($_ =~ /DISK/) { my $statusValue = 0; my @statusArray=split(' ',$_); my $unitStatus=$statusArray[2]; my $rebuildPercent=$statusArray[3]; if($unitStatus eq 'OK') { $statusValue = 2; } elsif ($unitStatus =~ /^VERIFY/) #Possible Status: VERIFYING and VERIFY-PAUSED { my $taskValue = 0; if($statusArray[4] =~ m/(\d+)/){ $taskValue = $1; } else { $taskValue = 0; } $statusValue = 1 + $taskValue/100; } elsif ($unitStatus =~ /^INIT/) #Possible Status: INITIALIZING and INIT-PAUSED { my $taskValue = 0; if($statusArray[4] =~ m/(\d+)/){ $taskValue = $1; } else { $taskValue = 0; } $statusValue = 1 + $taskValue/100; } elsif ($unitStatus =~ /^MIGRAT/) #Possible Status: MIGRATING and MIGRATE-PAUSED { my $taskValue = 0; if($statusArray[4] =~ m/(\d+)/){ $taskValue = $1; } else { $taskValue = 0; } $statusValue = 0 + $taskValue/100; } elsif ($unitStatus =~ /^REBUILD/) #Possible Status: REBUILDING and REBUILD-PAUSED { my $taskValue = 0; if($statusArray[3] =~ m/(\d+)/){ $taskValue = $1; } else { $taskValue = 0; } $statusValue = 0 + $taskValue/100; } print $statusArray[5].'.value '.$statusValue."\n"; } } } } sub Extract3WareControlers { my @stringArray; open (my $query_controlerList,$tw_cli." show|") or die "Could not open tw_cli, $!"; while(<$query_controlerList>) { if ($_ =~ m/(^c(\d)*)/) { my $controler_id = $1; open (my $query_unitcount,$tw_cli." /".$controler_id." show numunits|") or die "Could not open tw_cli, $!"; @stringArray = split("=",<$query_unitcount>); $stringArray[1] =~ m/(\d+)/; my $unitCount = $1; for(my $unitNumber = 0; $unitNumber < $unitCount; $unitNumber++) { print $controler_id.'_u'.$unitNumber.'\n'; } } } } my $progname; my $controler; my $unit; ($progname,$progname,$progname, $controler, $unit) = split(/_/, $0); my $unitQualifier='/'.$controler.'/'.$unit; if(not defined ($ARGV[0])) { $ARGV[0] = ""; } if($ARGV[0] eq "config") { print "graph_vlabel Status\n"; print "graph_scale yes\n"; print "graph_category raid\n"; print "graph_args --base 1000 --lower-limit 0 --upper-limit 2\n"; if(-e $tw_cli) { Extract3WareRaidUnit($unitQualifier,1); } } elsif($ARGV[0] eq "autoconf") { print "no\n"; } elsif($ARGV[0] eq "suggest") { if(-e $tw_cli) { Extract3WareControlers(); } } else { if(-e "/usr/local/bin/tw_cli") { Extract3WareRaidUnit($unitQualifier,0); } }