1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem;
our _æ_ ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem);
use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
sub new {
my $class = shift;
my %params = _æ_ _;
my $self = {
runtime => $params{runtime},
rawdata => $params{rawdata},
method => $params{method},
blacklisted => 0,
managers => [],
info => undef,
extendedinfo => undef,
};
bless $self, $class;
$self->init();
return $self;
}
sub init {
my $self = shift;
my $oids = {
cpqRackCommonEnclosureManagerEntry => '1.3.6.1.4.1.232.22.2.3.1.6.1',
cpqRackCommonEnclosureManagerRack => '1.3.6.1.4.1.232.22.2.3.1.6.1.1',
cpqRackCommonEnclosureManagerChassis => '1.3.6.1.4.1.232.22.2.3.1.6.1.2',
cpqRackCommonEnclosureManagerIndex => '1.3.6.1.4.1.232.22.2.3.1.6.1.3',
cpqRackCommonEnclosureManagerEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.6.1.4',
cpqRackCommonEnclosureManagerLocation => '1.3.6.1.4.1.232.22.2.3.1.6.1.5',
cpqRackCommonEnclosureManagerPartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.6',
cpqRackCommonEnclosureManagerSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.7',
cpqRackCommonEnclosureManagerSerialNum => '1.3.6.1.4.1.232.22.2.3.1.6.1.8',
cpqRackCommonEnclosureManagerRole => '1.3.6.1.4.1.232.22.2.3.1.6.1.9',
cpqRackCommonEnclosureManagerPresent => '1.3.6.1.4.1.232.22.2.3.1.6.1.10',
cpqRackCommonEnclosureManagerRedundant => '1.3.6.1.4.1.232.22.2.3.1.6.1.11',
cpqRackCommonEnclosureManagerCondition => '1.3.6.1.4.1.232.22.2.3.1.6.1.12',
cpqRackCommonEnclosureManagerFWRev => '1.3.6.1.4.1.232.22.2.3.1.6.1.15',
cpqRackCommonEnclosureManagerRoleValue => {
1 => 'standby',
2 => 'active',
},
cpqRackCommonEnclosureManagerPresentValue => {
1 => 'other',
2 => 'absent', # mit vorsicht zu geniessen!
3 => 'present',
},
cpqRackCommonEnclosureManagerRedundantValue => {
0 => 'other', # meiner phantasie entsprungen, da sich hp nicht aeussert
1 => 'other',
2 => 'notRedundant',
3 => 'redundant',
},
cpqRackCommonEnclosureManagerConditionValue => {
1 => 'other',
2 => 'ok',
3 => 'degraded',
4 => 'failed',
}
};
# INDEX { cpqRackCommonEnclosureManagerRack, cpqRackCommonEnclosureManagerChassis, cpqRackCommonEnclosureManagerIndex }
foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureManagerEntry')) {
push( _æ_ {$self->{managers}},
HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager->new(%{$_}));
}
}
sub check {
my $self = shift;
foreach ( _æ_ {$self->{managers}}) {
$_->check() if $_->{cpqRackCommonEnclosureManagerPresent} eq 'present' ||
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv
}
}
sub dump {
my $self = shift;
foreach ( _æ_ {$self->{managers}}) {
$_->dump() if $_->{cpqRackCommonEnclosureManagerPresent} eq 'present' ||
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv
}
}
package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager;
our _æ_ ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem);
use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
sub new {
my $class = shift;
my %params = _æ_ _;
my $self = {
runtime => $params{runtime},
rawdata => $params{rawdata},
method => $params{method},
blacklisted => 0,
info => undef,
extendedinfo => undef,
};
map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureManager/, keys %params;
$self->{name} = $self->{cpqRackCommonEnclosureManagerRack}.
':'.$self->{cpqRackCommonEnclosureManagerChassis}.
':'.$self->{cpqRackCommonEnclosureManagerIndex};
if ($self->{cpqRackCommonEnclosureManagerPresent} eq "absent" &&
defined $self->{cpqRackCommonEnclosureManagerEnclosureName}) {
$self->{cpqRackCommonEnclosureManagerPresent} = "present";
}
bless $self, $class;
return $self;
}
sub check {
my $self = shift;
$self->blacklist('em', $self->{name});
my $info = sprintf 'manager %s is %s, location is %s, redundance is %s, condition is %s, role is %s',
$self->{name}, $self->{cpqRackCommonEnclosureManagerPresent},
$self->{cpqRackCommonEnclosureManagerLocation},
$self->{cpqRackCommonEnclosureManagerRedundant},
$self->{cpqRackCommonEnclosureManagerCondition},
$self->{cpqRackCommonEnclosureManagerRole};
$self->add_info($info) if $self->{cpqRackCommonEnclosureManagerPresent} eq 'present' ||
$self->{runtime}->{options}->{verbose} >= 3; # absent managers nur bei -vvv
if ($self->{cpqRackCommonEnclosureManagerCondition} eq 'degraded') {
$self->{info} .= sprintf ' (SparePartNum: %s)',
$self->{cpqRackCommonEnclosureManagerSparePartNumber};
$self->add_message(WARNING, $self->{info});
} elsif ($self->{cpqRackCommonEnclosureManagerCondition} eq 'failed') {
$self->{info} .= sprintf ' (SparePartNum: %s)',
$self->{cpqRackCommonEnclosureManagerSparePartNumber};
$self->add_message(CRITICAL, $self->{info});
}
}
sub dump {
my $self = shift;
printf "[ENCLOSURE_MANAGER_%s]\n", $self->{name};
foreach (qw(cpqRackCommonEnclosureManagerRack cpqRackCommonEnclosureManagerChassis
cpqRackCommonEnclosureManagerIndex cpqRackCommonEnclosureManagerEnclosureName
cpqRackCommonEnclosureManagerLocation cpqRackCommonEnclosureManagerPartNumber
cpqRackCommonEnclosureManagerSparePartNumber cpqRackCommonEnclosureManagerPresent
cpqRackCommonEnclosureManagerRedundant
cpqRackCommonEnclosureManagerCondition cpqRackCommonEnclosureManagerFWRev)) {
printf "%s: %s\n", $_, $self->{$_};
}
printf "info: %s\n", $self->{info};
printf "\n";
}
1;
|