Skip to content

Commit 03ae764

Browse files
committed
hpacucli: parse controller status
1 parent 1624a55 commit 03ae764

File tree

14 files changed

+50
-7
lines changed

14 files changed

+50
-7
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ sub scan_targets {
8282
# [licensekey all|<key>]
8383

8484
# Scan controllers
85-
my (%targets);
85+
my (%targets, $target);
8686
my $fh = $this->cmd('controller status');
8787
while (<$fh>) {
88+
chomp;
89+
# skip empty lines and artificial comments (added by this project)
90+
next if /^$/ or /^#/;
91+
8892
# Numeric slot
8993
if (my($controller, $slot, $modes) = /
9094
^(\S.+)\sin\sSlot
@@ -94,8 +98,9 @@ sub scan_targets {
9498
)?$
9599
/x) {
96100
97-
$targets{"slot=$slot"} = {
98-
target => "slot=$slot",
101+
$target = "slot=$slot";
102+
$targets{$target} = {
103+
target => $target,
99104
controller => $controller,
100105
slot => $slot,
101106
modes => split_controller_modes($modes || ''),
@@ -105,13 +110,21 @@ sub scan_targets {
105110
}
106111
# Named Entry
107112
if (my($controller, $cn) = /^(\S.+) in (.+)/) {
108-
$targets{"chassisname=$cn"} = {
109-
target => "chassisname=$cn",
113+
$target = "chassisname=$cn";
114+
$targets{$target} = {
115+
target => $target,
110116
controller => $controller,
111117
chassisname => $cn,
112118
};
113119
next;
114120
}
121+
122+
# Other statuses, try "key: value" pairs
123+
if (my ($key, $value) = /^\s*(.+?):\s+(.+?)$/) {
124+
$targets{$target}{$key} = $value;
125+
} else {
126+
warn "Unparsed: [$_]\n";
127+
}
115128
}
116129
close $fh;
117130

t/data/hpacucli/151/controller

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
root@xxx:~# /usr/sbin/hpacucli controller all show status
1+
#root@xxx:~# /usr/sbin/hpacucli controller all show status
22

33
Smart Array P410i in Slot 0 (Embedded)
44
Controller Status: OK

t/data/hpacucli/issue139/controller

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[root@xxx ~]# /sbin/hpssacli controller all show status
1+
#[root@xxx ~]# /sbin/hpssacli controller all show status
22

33
Dynamic Smart Array B140i in Slot 0b
44
Controller Status: OK

t/dump/hpacucli/1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
$VAR1 = [
22
{
3+
'Battery/Capacitor Status' => 'OK',
4+
'Cache Status' => 'OK',
5+
'Controller Status' => 'OK',
36
'array' => [
47
{
58
'logicaldrives' => [
@@ -19,6 +22,9 @@ $VAR1 = [
1922
'target' => 'chassisname=MY STORAGE'
2023
},
2124
{
25+
'Battery/Capacitor Status' => 'OK',
26+
'Cache Status' => 'OK',
27+
'Controller Status' => 'OK',
2228
'array' => [
2329
{
2430
'logicaldrives' => [

t/dump/hpacucli/145

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$VAR1 = [
22
{
3+
'Controller Status' => 'OK',
34
'array' => [
45
{
56
'logicaldrives' => [
@@ -23,6 +24,7 @@ $VAR1 = [
2324
'target' => 'slot=0'
2425
},
2526
{
27+
'Controller Status' => 'OK',
2628
'array' => [
2729
{
2830
'logicaldrives' => [

t/dump/hpacucli/145_slot1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$VAR1 = [
22
{
3+
'Controller Status' => 'OK',
34
'array' => [
45
{
56
'logicaldrives' => [

t/dump/hpacucli/2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
$VAR1 = [
22
{
3+
'Battery/Capacitor Status' => 'OK',
4+
'Cache Status' => 'OK',
5+
'Controller Status' => 'OK',
36
'array' => [
47
{
58
'logicaldrives' => [
@@ -19,6 +22,9 @@ $VAR1 = [
1922
'target' => 'chassisname=MY STORAGE'
2023
},
2124
{
25+
'Battery/Capacitor Status' => 'OK',
26+
'Cache Status' => 'OK',
27+
'Controller Status' => 'OK',
2228
'array' => [
2329
{
2430
'logicaldrives' => [

t/dump/hpacucli/3

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
$VAR1 = [
22
{
3+
'Cache Status' => 'OK',
4+
'Controller Status' => 'OK',
35
'controller' => 'Smart Array P400',
46
'modes' => [],
57
'slot' => 'ATTR_VALUE_SLOT_UNKNOWN',

t/dump/hpacucli/4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
$VAR1 = [
22
{
3+
'Battery/Capacitor Status' => 'OK',
4+
'Cache Status' => 'OK',
5+
'Controller Status' => 'OK',
36
'array' => [
47
{
58
'logicaldrives' => [

t/dump/hpacucli/5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
$VAR1 = [
22
{
3+
'Battery/Capacitor Status' => 'OK',
4+
'Cache Status' => 'OK',
5+
'Controller Status' => 'OK',
36
'array' => [
47
{
58
'logicaldrives' => [

0 commit comments

Comments
 (0)