diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/check_linux_raid.pl | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl index 85d5dc4..11bc3cd 100644 --- a/contrib/check_linux_raid.pl +++ b/contrib/check_linux_raid.pl | |||
@@ -20,7 +20,7 @@ | |||
20 | # | 20 | # |
21 | # Usage: check_raid [raid-name] | 21 | # Usage: check_raid [raid-name] |
22 | # Example: check_raid md0 | 22 | # Example: check_raid md0 |
23 | # WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min | 23 | # WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min |
24 | 24 | ||
25 | use strict; | 25 | use strict; |
26 | use lib utils.pm; | 26 | use lib utils.pm; |
@@ -61,19 +61,17 @@ while(defined $nextdev){ | |||
61 | if (defined $device) { | 61 | if (defined $device) { |
62 | if (/(\[[_U]+\])/) { | 62 | if (/(\[[_U]+\])/) { |
63 | $status{$device} = $1; | 63 | $status{$device} = $1; |
64 | $device = undef; | ||
65 | } elsif (/recovery = (.*?)\s/) { | 64 | } elsif (/recovery = (.*?)\s/) { |
66 | $recovery{$device} = $1; | 65 | $recovery{$device} = $1; |
67 | ($finish{$device}) = /finish=(.*?min)/; | 66 | ($finish{$device}) = /finish=(.*?min)/; |
68 | $device = undef; | 67 | } elsif (/^\s*$/) { |
68 | $device=undef; | ||
69 | } | 69 | } |
70 | } else { | 70 | } elsif (/^($nextdev)\s*:/) { |
71 | if (/^($nextdev)\s*:/) { | 71 | $device=$1; |
72 | $device=$1; | 72 | $devices{$device}=$device; |
73 | $devices{$device}=$device; | 73 | if (/active/) { |
74 | if (/active/) { | 74 | $active{$device} = 1; |
75 | $active{$device} = 1; | ||
76 | } | ||
77 | } | 75 | } |
78 | } | 76 | } |
79 | } | 77 | } |
@@ -82,7 +80,7 @@ while(defined $nextdev){ | |||
82 | 80 | ||
83 | foreach my $k (sort keys %devices){ | 81 | foreach my $k (sort keys %devices){ |
84 | if ($status{$k} =~ /_/) { | 82 | if ($status{$k} =~ /_/) { |
85 | if ($recovery{$k}) { | 83 | if (defined $recovery{$k}) { |
86 | $msg .= sprintf " %s status=%s, recovery=%s, finish=%s.", | 84 | $msg .= sprintf " %s status=%s, recovery=%s, finish=%s.", |
87 | $devices{$k}, $status{$k}, $recovery{$k}, $finish{$k}; | 85 | $devices{$k}, $status{$k}, $recovery{$k}, $finish{$k}; |
88 | $code = max_state($code, "WARNING"); | 86 | $code = max_state($code, "WARNING"); |