Skip to content

Commit 85423dd

Browse files
committed
hpacucli: handle not configured controller with noraid status code. #145, #151
1 parent 2ad9329 commit 85423dd

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

lib/App/Monitoring/Plugin/CheckRaid/Plugins/hpacucli.pm

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use base 'App::Monitoring::Plugin::CheckRaid::Plugin';
1212
use strict;
1313
use warnings;
1414

15+
use constant E_NO_LOGICAL_DEVS => 'The specified device does not have any logical drives';
16+
1517
sub 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

279292
sub 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;

t/check_hpacucli.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ my @tests = (
2929
status => UNKNOWN,
3030
controller => 'heracles/controller.all.show.status',
3131
logical => 'heracles/logicaldrive.all.show',
32-
message => 'Smart Array P400[OK]: ',
32+
message => 'Smart Array P400[OK, Invalid target syntax. "attr_value_slot_unknown" is not a valid target]',
3333
c => '3',
3434
},
3535
{
@@ -72,7 +72,7 @@ my @tests = (
7272
status => UNKNOWN,
7373
controller => '145/controller',
7474
logical => '145/logicaldrive.slot1',
75-
message => 'Smart Array P840[OK]: ',
75+
message => 'Smart Array P840[OK, Not configured]',
7676
targets => 'slot=1',
7777
c => '145_slot1',
7878
},
@@ -96,7 +96,7 @@ my @tests = (
9696
status => UNKNOWN,
9797
controller => '151/controller',
9898
logical => '151/logicaldrive.slot3',
99-
message => 'Smart Array P411[OK]: ',
99+
message => 'Smart Array P411[OK, Not configured]',
100100
targets => 'slot=3',
101101
c => 'issue151_3',
102102
},

t/dump/hpacucli/145_slot1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $VAR1 = [
22
{
33
'Controller Status' => 'OK',
44
'controller' => 'Smart Array P840',
5-
'error' => 'Error: The specified device does not have any logical drives.',
5+
'error' => 'The specified device does not have any logical drives',
66
'modes' => [
77
'HBA Mode'
88
],

t/dump/hpacucli/3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $VAR1 = [
33
'Cache Status' => 'OK',
44
'Controller Status' => 'OK',
55
'controller' => 'Smart Array P400',
6-
'error' => 'Error: Invalid target syntax. "attr_value_slot_unknown" is not a valid target. ',
6+
'error' => 'Invalid target syntax. "attr_value_slot_unknown" is not a valid target',
77
'modes' => [],
88
'slot' => 'ATTR_VALUE_SLOT_UNKNOWN',
99
'target' => 'slot=ATTR_VALUE_SLOT_UNKNOWN'

t/dump/hpacucli/issue151_3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $VAR1 = [
33
'Cache Status' => 'Not Configured',
44
'Controller Status' => 'OK',
55
'controller' => 'Smart Array P411',
6-
'error' => 'Error: The specified device does not have any logical drives.',
6+
'error' => 'The specified device does not have any logical drives',
77
'modes' => [],
88
'slot' => '3',
99
'target' => 'slot=3'

0 commit comments

Comments
 (0)