X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=contrib%2Fcheck_linux_raid.pl;h=da1aff84790fa2e74ae8480aa2f0032834e65a08;hb=be144b672094a11b6a670df9562e26e6a56ff03f;hp=85d5dc4a8da5c6a697765ad9773bb8d76031e146;hpb=4522ae336de629b405572c83f5bb59a68f979cc0;p=nagiosplug.git diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl index 85d5dc4..da1aff8 100644 --- a/contrib/check_linux_raid.pl +++ b/contrib/check_linux_raid.pl @@ -20,10 +20,10 @@ # # Usage: check_raid [raid-name] # Example: check_raid md0 -# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min +# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min use strict; -use lib utils.pm; +use lib "/usr/local/nagios/libexec"; use utils qw(%ERRORS); # die with an error if we're not on Linux @@ -61,19 +61,17 @@ while(defined $nextdev){ if (defined $device) { if (/(\[[_U]+\])/) { $status{$device} = $1; - $device = undef; } elsif (/recovery = (.*?)\s/) { $recovery{$device} = $1; ($finish{$device}) = /finish=(.*?min)/; - $device = undef; + } elsif (/^\s*$/) { + $device=undef; } - } else { - if (/^($nextdev)\s*:/) { - $device=$1; - $devices{$device}=$device; - if (/active/) { - $active{$device} = 1; - } + } elsif (/^($nextdev)\s*:/) { + $device=$1; + $devices{$device}=$device; + if (/active/) { + $active{$device} = 1; } } } @@ -82,7 +80,7 @@ while(defined $nextdev){ foreach my $k (sort keys %devices){ if ($status{$k} =~ /_/) { - if ($recovery{$k}) { + if (defined $recovery{$k}) { $msg .= sprintf " %s status=%s, recovery=%s, finish=%s.", $devices{$k}, $status{$k}, $recovery{$k}, $finish{$k}; $code = max_state($code, "WARNING");