@@ -12,6 +12,8 @@ use base 'App::Monitoring::Plugin::CheckRaid::Plugin';
1212use strict;
1313use warnings;
1414
15+ use constant E_NO_LOGICAL_DEVS => ' The specified device does not have any logical drives' ;
16+
1517sub program_names {
1618 shift -> {name };
1719}
@@ -150,9 +152,9 @@ sub scan_luns {
150152 next if / ^$ / or /^# /;
151153
152154 # Error: The controller identified by "slot=attr_value_slot_unknown" was not detected.
153- if (/ Error:/ ) {
155+ if (/ ^ Error:\s / ) {
154156 # store it somewhere. should it be appended?
155- $target -> {' error' } = $_ ;
157+ ( $target -> {' error' }) = /^Error:\ s +(.+?)\.?\ s * $/ ;
156158 $this -> unknown;
157159 next ;
158160 }
@@ -256,10 +258,21 @@ sub cstatus {
256258 my (@s , $s );
257259
258260 # always include controller status
259- push (@s , $c -> {' Controller Status' });
261+ push (@s , $c -> {' Controller Status' } || ' ERROR ' );
260262 if ($c -> {' Controller Status' } ne ' OK' ) {
261263 $this -> critical;
262264 }
265+
266+ if ($c -> {error }) {
267+ if ($c -> {error } eq E_NO_LOGICAL_DEVS) {
268+ $this -> noraid;
269+ push (@s , ' Not configured' );
270+ } else {
271+ $this -> unknown;
272+ push (@s , $c -> {error });
273+ }
274+ }
275+
263276 # print those only if not ok and configured
264277 if (($s = $c -> {' Cache Status' }) && $s !~ / ^(OK|Not Configured)/ ) {
265278 push (@s , " Cache: $s " );
@@ -273,7 +286,7 @@ sub cstatus {
273286 # start with identifyier
274287 my $name = $c -> {chassisname } || $c -> {controller };
275288
276- return $name . ' [' . join (' ' , @s ) . ' ]' ;
289+ return $name . ' [' . join (' , ' , @s ) . ' ]' ;
277290}
278291
279292sub check {
@@ -295,7 +308,9 @@ sub check {
295308 }
296309 push (@astatus , $this -> astatus($array ). ' [' . join (' ,' , @lstatus ). ' ]' );
297310 }
298- push (@status , $this -> cstatus($ctrl ). ' : ' . join (' , ' , @astatus ));
311+ my $cstatus = $this -> cstatus($ctrl );
312+ $cstatus .= ' : ' . join (' , ' , @astatus ) if @astatus ;
313+ push (@status , $cstatus );
299314 }
300315
301316 return unless @status ;
0 commit comments