summaryrefslogtreecommitdiffstats
path: root/contrib/check_linux_raid.pl
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/check_linux_raid.pl')
-rw-r--r--contrib/check_linux_raid.pl20
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl
index c24b0cd..6650a42 100644
--- a/contrib/check_linux_raid.pl
+++ b/contrib/check_linux_raid.pl
@@ -28,8 +28,8 @@ use utils qw(%ERRORS);
28 28
29# die with an error if we're not on Linux 29# die with an error if we're not on Linux
30if ($^O ne 'linux') { 30if ($^O ne 'linux') {
31 print "This plugin only applicable on Linux.\n"; 31 print "This plugin only applicable on Linux.\n";
32 exit $ERRORS{'UNKNOWN'}; 32 exit $ERRORS{'UNKNOWN'};
33} 33}
34 34
35sub max_state($$){ 35sub max_state($$){
@@ -50,6 +50,7 @@ my $code = "UNKNOWN";
50my $msg = ""; 50my $msg = "";
51my %status; 51my %status;
52my %recovery; 52my %recovery;
53my %resyncing;
53my %finish; 54my %finish;
54my %active; 55my %active;
55my %devices; 56my %devices;
@@ -65,6 +66,10 @@ while(defined $nextdev){
65 $recovery{$device} = $1; 66 $recovery{$device} = $1;
66 ($finish{$device}) = /finish=(.*?min)/; 67 ($finish{$device}) = /finish=(.*?min)/;
67 $device=undef; 68 $device=undef;
69 } elsif (/resync =\s+(.*?)\s/) {
70 $resyncing{$device} = $1;
71 ($finish{$device}) = /finish=(.*?min)/;
72 $device=undef;
68 } elsif (/^\s*$/) { 73 } elsif (/^\s*$/) {
69 $device=undef; 74 $device=undef;
70 } 75 }
@@ -95,8 +100,14 @@ foreach my $k (sort keys %devices){
95 $code = max_state($code, "CRITICAL"); 100 $code = max_state($code, "CRITICAL");
96 } 101 }
97 } elsif ($status{$k} =~ /U+/) { 102 } elsif ($status{$k} =~ /U+/) {
98 $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k}; 103 if (defined $resyncing{$k}) {
99 $code = max_state($code, "OK"); 104 $msg .= sprintf " %s status=%s, resync=%s, finish=%s.",
105 $devices{$k}, $status{$k}, $resyncing{$k}, $finish{$k};
106 $code = max_state($code, "WARNING");
107 } else {
108 $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k};
109 $code = max_state($code, "OK");
110 }
100 } else { 111 } else {
101 if ($active{$k}) { 112 if ($active{$k}) {
102 $msg .= sprintf " %s active with no status information.", 113 $msg .= sprintf " %s active with no status information.",
@@ -112,4 +123,3 @@ foreach my $k (sort keys %devices){
112 123
113print $code, $msg, "\n"; 124print $code, $msg, "\n";
114exit ($ERRORS{$code}); 125exit ($ERRORS{$code});
115