mirror of
https://github.com/thomas-krenn/check_lsi_raid.git
synced 2025-07-14 03:41:50 +02:00
Rewrite given/when to if/elsif
-Added eclipse project files -Remove tmp POD files
This commit is contained in:
3
.includepath
Normal file
3
.includepath
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<includepath />
|
||||
|
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>check_lsi_raid</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.epic.perleditor.perlbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.epic.perleditor.perlnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
128
check_lsi_raid
128
check_lsi_raid
@ -27,8 +27,6 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long qw(:config no_ignore_case);
|
||||
use feature qw/switch/; #sp<73>ter durch nachfolgende Zeile ersetzen, da wir noch mit Perl 5 arbeiten!
|
||||
#use Switch 'Perl6';
|
||||
|
||||
our $VERBOSITY = 0;
|
||||
our $VERSION = "0.3";
|
||||
@ -86,15 +84,18 @@ sub displayUsage {
|
||||
sub displayHelp {
|
||||
print $NAME . " Version: " . $VERSION ."\n";
|
||||
print "Copyright (C) 2009-2013 Thomas-Krenn.AG\n";
|
||||
print "Current updates available at http://www.thomas-krenn.com/en/oss/<NOT HERE YET!!!!!!>/\n";
|
||||
print "Current updates available at http://git.thomas-krenn.com/check_lsi_raid.git\n";
|
||||
print "This Nagios/Icinga Plugin checks LSI RAID-Controllers for Controller, \nPhysical-Device and Logical Device warnings and errors.\n";
|
||||
print "In order for this plugin to work properly you need to add the \nnagios-user to your sudoers file (or create a new one in /etc/sudoers.d/)\n";
|
||||
displayUsage();
|
||||
print "Further information about this plugin can be found at
|
||||
http://www.thomas-krenn.com/en/oss/<NOT THERE YET!>
|
||||
Send email to the <NOT THERE YET!>-plugin-user mailing list if you have questions regarding
|
||||
use of this software, to submit patches, or suggest improvements.
|
||||
The mailing list is available at http://lists.thomas-krenn.com/\n";
|
||||
print "Further information about this plugin can be found at:
|
||||
http://www.thomas-krenn.com/de/wiki/LSI_RAID_Monitoring_Plugin and
|
||||
http://www.thomas-krenn.com/de/wiki/LSI_RAID_Monitoring_Plugin
|
||||
Please send an email to the tk-monitoring plugin-user mailing list:
|
||||
tk-monitoring-plugins-user\@lists.thomas-krenn.com
|
||||
if you have questions regarding use of this software, to submit patches, or
|
||||
suggest improvements. The mailing list archive is available at:
|
||||
http://lists.thomas-krenn.com/pipermail/tk-monitoring-plugins-user\n";
|
||||
exit(STATE_OK);
|
||||
}
|
||||
|
||||
@ -140,29 +141,27 @@ sub getControllerStatus {
|
||||
$first = $1;
|
||||
if($line =~ /([a-zA-Z0-9]*)$/) {
|
||||
$last = $1;
|
||||
given($first) {
|
||||
when("Controller") {
|
||||
if($first eq "Controller") {
|
||||
if($line =~ /\s+([a-zA-Z0-9]*)/) {
|
||||
given($1) {
|
||||
when("Status") {
|
||||
if($1 eq "Status") {
|
||||
if($last ne "OK") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "Ctrl. status not optimal, ";
|
||||
}
|
||||
}
|
||||
when("must") {
|
||||
elsif($1 eq "must") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
$statusMessage .= "Ctrl. needs reboot, ";
|
||||
}
|
||||
}
|
||||
when("has") {
|
||||
elsif($1 eq "has") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "Ctrl. booted in safe mode, ";
|
||||
}
|
||||
}
|
||||
when("temperature") {
|
||||
elsif($1 eq "temperature") {
|
||||
$temp = $last;
|
||||
if($temperature_w[0] eq "in") {
|
||||
if(($temp >= $temperature_w[1]) && ($temp <= $temperature_w[2])) {
|
||||
@ -226,8 +225,7 @@ sub getControllerStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
when("ROC") {
|
||||
elsif($first eq "ROC") {
|
||||
if($line =~ /\s+([a-zA-Z0-9]*)/) {
|
||||
if($1 eq "temperature") {
|
||||
$temp = $last;
|
||||
@ -293,16 +291,15 @@ sub getControllerStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
when("Memory") {
|
||||
elsif($first eq "Memory") {
|
||||
if($line =~ /(\s+[a-zA-Z0-9]*)/) {
|
||||
given($1) {
|
||||
when("Correctable") {
|
||||
if($1 eq "Correctable") {
|
||||
if($last ne "0") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "Memory correctable errors detected, ";
|
||||
}
|
||||
}
|
||||
when("Uncorrectable") {
|
||||
elsif($1 eq "Uncorrectable") {
|
||||
if($last ne "0") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
$statusMessage .= "Memory uncorrectable errors detected, ";
|
||||
@ -310,14 +307,13 @@ sub getControllerStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
when("Failed") {
|
||||
elsif($first eq "Failed") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "Failed to get lock key on bootup, ";
|
||||
}
|
||||
}
|
||||
when("A") {
|
||||
elsif($first eq "A") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "A rollback operation is in progress, ";
|
||||
@ -326,7 +322,6 @@ sub getControllerStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($status, $statusMessage);
|
||||
} else {
|
||||
print "Invalid StorCLI command!";
|
||||
@ -347,11 +342,10 @@ sub getLogicalDeviceStatus {
|
||||
my $status = 0; # Return Status
|
||||
my $statusMessage = ''; # Return String
|
||||
|
||||
given(scalar(@logDevices)) {
|
||||
when(0) { $command .= "/vall"; }
|
||||
when(1) { $command .= "/v$logDevices[0]"; }
|
||||
default { $command .= "/v".join(",", @logDevices); }
|
||||
}
|
||||
if(scalar(@logDevices) == 0) { $command .= "/vall"; }
|
||||
elsif(scalar(@logDevices) == 1) { $command .= "/v$logDevices[0]"; }
|
||||
else { $command .= "/v".join(",", @logDevices); }
|
||||
|
||||
$command .= " show $action";
|
||||
my @output = `$command`;
|
||||
|
||||
@ -435,16 +429,14 @@ sub getPhysDeviceStatus {
|
||||
my $status = 0;
|
||||
my $statusMessage = '';
|
||||
|
||||
given(scalar(@enclosures)) {
|
||||
when(0) { $command .= "/eall"; }
|
||||
when(1) { $command .= "/e$enclosures[0]"; }
|
||||
default { $command .= "/e".join(",", @enclosures); }
|
||||
}
|
||||
given(scalar(@physDevices)) {
|
||||
when(0) { $command .= "/sall"; }
|
||||
when(1) { $command .= "/s$physDevices[0]"; }
|
||||
default { $command .= "/s".join(",", @physDevices); }
|
||||
}
|
||||
if(scalar(@enclosures) == 0) { $command .= "/eall"; }
|
||||
elsif(scalar(@enclosures) == 1) { $command .= "/e$enclosures[0]"; }
|
||||
else { $command .= "/e".join(",", @enclosures); }
|
||||
|
||||
if(scalar(@physDevices) == 0) { $command .= "/sall"; }
|
||||
elsif(scalar(@physDevices) == 1) { $command .= "/s$physDevices[0]"; }
|
||||
else { $command .= "/s".join(",", @physDevices); }
|
||||
|
||||
$command .= " show $action";
|
||||
my @output = `$command`;
|
||||
|
||||
@ -484,8 +476,7 @@ sub getPhysDeviceStatus {
|
||||
}
|
||||
} elsif($values[0] =~ /^[a-zA-Z\.]*/) {
|
||||
# Check the drive state in block Detailed information
|
||||
given($values[0]) {
|
||||
when("Shield") {
|
||||
if($values[0] eq "Shield") {
|
||||
if($values[3] ne "0") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "Shield counter (phys. drive) not 0, "; }
|
||||
@ -493,7 +484,7 @@ sub getPhysDeviceStatus {
|
||||
if ($VERBOSITY >= 2) {$statusMessage .= "Physical drive $output_dev in enclosure $output_enc: shield counter not 0, "; }
|
||||
}
|
||||
}
|
||||
when("Media") {
|
||||
elsif($values[0] eq "Media") {
|
||||
if($values[4] ne "0") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "Media error count (phys. drive) not 0, "; }
|
||||
@ -501,7 +492,7 @@ sub getPhysDeviceStatus {
|
||||
if ($VERBOSITY >= 2) {$statusMessage .= "Physical drive $output_dev in enclosure $output_enc: media error count not 0, "; }
|
||||
}
|
||||
}
|
||||
when("Other") {
|
||||
elsif($values[0] eq "Other") {
|
||||
if($values[4] ne "0") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "Other error count (phys. drive) not 0, "; }
|
||||
@ -509,7 +500,7 @@ sub getPhysDeviceStatus {
|
||||
if ($VERBOSITY >= 2) {$statusMessage .= "Physical drive $output_dev in enclosure $output_enc: media error count not 0, "; }
|
||||
}
|
||||
}
|
||||
when("Drive") {
|
||||
elsif($values[0] eq "Drive") {
|
||||
chop($values[3]);
|
||||
my $temp = $values[3];
|
||||
my $crit = 0;
|
||||
@ -574,7 +565,7 @@ sub getPhysDeviceStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
when("Predictive") {
|
||||
elsif($values[0] eq "Predictive") {
|
||||
if($values[4] ne "0") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "Phys. drive Predictive Fail Count not 0, "; }
|
||||
@ -582,7 +573,7 @@ sub getPhysDeviceStatus {
|
||||
if ($VERBOSITY >= 2) {$statusMessage .= "Physical drive $output_dev in enclosure $output_enc: Predictive Fail Count not 0, "; }
|
||||
}
|
||||
}
|
||||
when("S.M.A.R.T") {
|
||||
elsif($values[0] eq "S.M.A.R.T") {
|
||||
if($values[6] ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "S.M.A.R.T alert flagged by drive, "; }
|
||||
@ -590,7 +581,6 @@ sub getPhysDeviceStatus {
|
||||
if ($VERBOSITY >= 2) {$statusMessage .= "Physical drive $output_dev in enclosure $output_enc: S.M.A.R.T alert flagged, "; }
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$flag = -1;
|
||||
}
|
||||
@ -652,11 +642,9 @@ sub getBBUStatus {
|
||||
$last = $1;
|
||||
# Check BBU_Info block
|
||||
if ($blockid eq 1) {
|
||||
given($first) {
|
||||
when("Battery") {
|
||||
if($first eq "Battery") {
|
||||
if($line =~ /\s+([a-zA-Z0-9]*)/) {
|
||||
given($1) {
|
||||
when("State") {
|
||||
if($1 eq "State") {
|
||||
if($last ne "Optimal") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "BBU state not optimal, ";
|
||||
@ -665,34 +653,30 @@ sub getBBUStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# Check BBU_Firmware_Status
|
||||
if ($blockid eq 2) {
|
||||
given($first) {
|
||||
when("Temperature") {
|
||||
if($first eq "Temperature") {
|
||||
if($last ne "OK") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "BBU temp. critical, "; }
|
||||
if ($VERBOSITY >= 1) {$statusMessage .= "BBU Temperature critical, "; }
|
||||
}
|
||||
}
|
||||
when("Battery") {
|
||||
elsif($first eq "Battery") {
|
||||
if($line =~ /\s+([a-zA-Z0-9]*)/) {
|
||||
given($1) {
|
||||
when("State") {
|
||||
if($1 eq "State") {
|
||||
if($last ne "Optimal") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "BBU state not optimal, ";
|
||||
}
|
||||
}
|
||||
when("Pack") {
|
||||
elsif($1 eq "Pack") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
$statusMessage .= "BBU pack missing, ";
|
||||
}
|
||||
}
|
||||
when("Replacement") {
|
||||
elsif($1 eq "Replacement") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "BBU replacement required, ";
|
||||
@ -700,26 +684,25 @@ sub getBBUStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
when("Voltage") {
|
||||
elsif($first eq "Voltage") {
|
||||
if($last ne "OK") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
$statusMessage .= "BBU voltage not ok, ";
|
||||
}
|
||||
}
|
||||
when("Learn") {
|
||||
elsif($first eq "Learn") {
|
||||
if($last ne "OK") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
$statusMessage .= "BBU learn cycle status not ok, ";
|
||||
}
|
||||
}
|
||||
when("I2C") {
|
||||
elsif($first eq "I2C") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_CRITICAL);
|
||||
$statusMessage .= "BBU I2C errors, ";
|
||||
}
|
||||
}
|
||||
when("Remaining") {
|
||||
elsif($first eq "Remaining") {
|
||||
if($last ne "No") {
|
||||
$status = getExitState($status, STATE_WARNING);
|
||||
if ($VERBOSITY == 0) {$statusMessage .= "BBU capacity low, "; }
|
||||
@ -727,11 +710,9 @@ sub getBBUStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# Check GasGaugeStatus
|
||||
if ($blockid eq 3) {
|
||||
given($first) {
|
||||
when("Over") {
|
||||
if($first eq "Over") {
|
||||
if($line =~ /\s+([a-zA-Z0-9]*)/) {
|
||||
if($1 eq "Temperature") {
|
||||
if($last ne "No") {
|
||||
@ -751,7 +732,6 @@ sub getBBUStatus {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($status, $statusMessage);
|
||||
} else {
|
||||
print "Invalid StorCLI command!";
|
||||
@ -954,10 +934,8 @@ MAIN: {
|
||||
$newstatusMessage .= $statusMessage;
|
||||
$exitstatus = getExitState($newexitstatus, $exitstatus);
|
||||
}
|
||||
given($exitstatus) {
|
||||
when(0) { print "LSIRAID OK (Ctrl #$controller)\n"; }
|
||||
when(1) { chop($newstatusMessage); chop($newstatusMessage); print "LSIRAID WARNING (Ctrl #$controller): [$newstatusMessage]\n"; }
|
||||
when(2) { chop($newstatusMessage); chop($newstatusMessage); print "LSIRAID CRITICAL (Ctrl #$controller): [$newstatusMessage]\n"; }
|
||||
}
|
||||
if($exitstatus == 0) { print "LSIRAID OK (Ctrl #$controller)\n"; }
|
||||
elsif($exitstatus == 1) { chop($newstatusMessage); chop($newstatusMessage); print "LSIRAID WARNING (Ctrl #$controller): [$newstatusMessage]\n"; }
|
||||
elsif($exitstatus == 2) { chop($newstatusMessage); chop($newstatusMessage); print "LSIRAID CRITICAL (Ctrl #$controller): [$newstatusMessage]\n"; }
|
||||
exit($exitstatus);
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ It checks the controller, the physical devices and the logical devices seperatel
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long qw(:config no_ignore_case);
|
||||
use Switch 'Perl6';
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
@ -83,7 +82,8 @@ Returns information about physical devices attached to the LSI raid-controller:
|
||||
- Predictive fail count
|
||||
- S.M.A.R.T. status
|
||||
|
||||
The device temperature can be set to a warning (parameter: B<-PDTw>|B<--physicaldevicetemperature-warn>) and a critical level (parameter: B<-PDTc>|B<--physicaldevicetemperature-critical>). See getThresholds for more information.
|
||||
The device temperature can be set to a warning (parameter: B<-PDTw>|B<--physicaldevicetemperature-warn>)
|
||||
and a critical level (parameter: B<-PDTc>|B<--physicaldevicetemperature-critical>). See getThresholds for more information.
|
||||
|
||||
=head2 getBBUStatus
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
|
||||
.
|
Reference in New Issue
Block a user