Debian Codegraph @

check_hpasm/src/plugins-scripts/HP/Proliant/Component/DiskSubsystem/Fca.pm

raw
1 package HP::Proliant::Component::DiskSubsystem::Fca;
2 our @ISA = qw(HP::Proliant::Component::DiskSubsystem);
3
4 use strict;
5 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
6
7 sub new {
8 my $class = shift;
9 my %params = @_;
10 my $self = {
11 runtime => $params{runtime},
12 rawdata => $params{rawdata},
13 method => $params{method},
14 host_controllers => [],
15 controllers => [],
16 accelerators => [],
17 enclosures => [],
18 physical_drives => [],
19 logical_drives => [],
20 spare_drives => [],
21 global_status => undef,
22 blacklisted => 0,
23 };
24 bless $self, $class;
25 if ($self->{method} eq 'snmp') {
26 bless $self, 'HP::Proliant::Component::DiskSubsystem::Fca::SNMP';
27 } else {
28 bless $self, 'HP::Proliant::Component::DiskSubsystem::Fca::CLI';
29 }
30 $self->init();
31 $self->assemble();
32 return $self;
33 }
34
35 sub assemble {
36 my $self = shift;
37 $self->trace(3, sprintf "%s controllers und platten zusammenfuehren",
38 ref($self));
39 $self->trace(3, sprintf "has %d host controllers",
40 scalar(@{$self->{host_controllers}}));
41 $self->trace(3, sprintf "has %d controllers",
42 scalar(@{$self->{controllers}}));
43 $self->trace(3, sprintf "has %d physical_drives",
44 scalar(@{$self->{physical_drives}}));
45 $self->trace(3, sprintf "has %d logical_drives",
46 scalar(@{$self->{logical_drives}}));
47 $self->trace(3, sprintf "has %d spare_drives",
48 scalar(@{$self->{spare_drives}}));
49 }
50
51 sub check {
52 my $self = shift;
53 foreach (@{$self->{host_controllers}}) {
54 $_->check();
55 }
56 foreach (@{$self->{controllers}}) {
57 $_->check();
58 }
59 foreach (@{$self->{accelerators}}) {
60 $_->check();
61 }
62 foreach (@{$self->{logical_drives}}) {
63 $_->check();
64 }
65 foreach (@{$self->{physical_drives}}) {
66 $_->check();
67 }
68 # wozu eigentlich?
69 #if (! $self->has_controllers()) {
70 #$self->{global_status}->check();
71 #}
72 }
73
74 sub dump {
75 my $self = shift;
76 foreach (@{$self->{host_controllers}}) {
77 $_->dump();
78 }
79 foreach (@{$self->{controllers}}) {
80 $_->dump();
81 }
82 foreach (@{$self->{accelerators}}) {
83 $_->dump();
84 }
85 foreach (@{$self->{logical_drives}}) {
86 $_->dump();
87 }
88 foreach (@{$self->{physical_drives}}) {
89 $_->dump();
90 }
91 #$self->{global_status}->dump();
92 }
93
94
95 package HP::Proliant::Component::DiskSubsystem::Fca::GlobalStatus;
96 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
97
98 use strict;
99 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
100
101 sub new {
102 my $class = shift;
103 my %params = @_;
104 my $self = {
105 runtime => $params{runtime},
106 cpqFcaMibCondition => $params{cpqFcaMibCondition},
107 };
108 bless $self, $class;
109 return $self;
110 }
111
112 sub check {
113 my $self = shift;
114 if ($self->{cpqFcaMibCondition} eq 'other') {
115 $self->add_message(OK,
116 sprintf 'fcal overall condition is other, update your drivers, please');
117 } elsif ($self->{cpqFcaMibCondition} ne 'ok') {
118 $self->add_message(CRITICAL,
119 sprintf 'fcal overall condition is %s', $self->{cpqFcaMibCondition});
120 }
121 $self->{info} =
122 sprintf 'fcal overall condition is %s', $self->{cpqFcaMibCondition};
123 }
124
125 sub dump {
126 my $self = shift;
127 printf "[FCAL]\n";
128 foreach (qw(cpqFcaMibCondition)) {
129 printf "%s: %s\n", $_, $self->{$_};
130 }
131 printf "\n";
132 }
133
134
135 package HP::Proliant::Component::DiskSubsystem::Fca::HostController;
136 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
137
138 use strict;
139 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
140
141 sub new {
142 my $class = shift;
143 my %params = @_;
144 my $self = {
145 runtime => $params{runtime},
146 blacklisted => 0,
147 info => undef,
148 extendedinfo => undef,
149 };
150 map { $self->{$_} = $params{$_} } grep /cpqFcaHostCntlr/, keys %params;
151 $self->{name} = $params{name} || $self->{cpqFcaHostCntlrIndex};
152 $self->{controllerindex} = $self->{cpqFcaHostCntlrIndex};
153 bless $self, $class;
154 return $self;
155 }
156
157 sub check {
158 my $self = shift;
159 $self->blacklist('fcahc', $self->{name});
160 my $info = sprintf 'fcal host controller %s in slot %s is %s',
161 $self->{name}, $self->{cpqFcaHostCntlrSlot}, $self->{cpqFcaHostCntlrCondition};
162 if ($self->{cpqFcaHostCntlrCondition} eq 'other') {
163 #$info .= sprintf ' and needs attention (%s)', $self->{cpqFcaHostCntlrStatus};
164 # let's assume other=ok
165 $self->add_message(OK, $info);
166 $self->add_info($info);
167 } elsif ($self->{cpqFcaHostCntlrCondition} ne 'ok') {
168 $self->add_message(CRITICAL, $info);
169 $self->add_info($info);
170 } else {
171 $self->add_info($info);
172 }
173 $self->blacklist('fcahco', $self->{name});
174 $info = sprintf 'fcal host controller %s overall condition is %s',
175 $self->{name}, $self->{cpqFcaHostCntlrOverallCondition};
176 if ($self->{cpqFcaHostCntlrOverallCondition} eq 'other') {
177 $self->add_message(OK, $info);
178 } elsif ($self->{cpqFcaHostCntlrOverallCondition} ne 'ok') {
179 $self->add_message(WARNING, $info);
180 }
181 $self->add_info($info);
182 }
183
184 sub dump {
185 my $self = shift;
186 printf "[FCAL_HOST_CONTROLLER_%s]\n", $self->{name};
187 foreach (qw(cpqFcaHostCntlrIndex cpqFcaHostCntlrSlot
188 cpqFcaHostCntlrModel cpqFcaHostCntlrStatus cpqFcaHostCntlrCondition
189 cpqFcaHostCntlrOverallCondition)) {
190 printf "%s: %s\n", $_, $self->{$_};
191 }
192 printf "\n";
193 }
194
195
196 package HP::Proliant::Component::DiskSubsystem::Fca::Controller;
197 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
198
199 use strict;
200 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
201
202 sub new {
203 my $class = shift;
204 my %params = @_;
205 my $self = {
206 runtime => $params{runtime},
207 blacklisted => 0,
208 info => undef,
209 extendedinfo => undef,
210 };
211 map { $self->{$_} = $params{$_} } grep /cpqFcaCntlr/, keys %params;
212 $self->{name} = $params{name} ||
213 $self->{cpqFcaCntlrBoxIndex}.':'.$self->{cpqFcaCntlrBoxIoSlot};
214 $self->{controllerindex} = $self->{cpqFcaCntlrBoxIndex};
215 bless $self, $class;
216 return $self;
217 }
218
219 sub check {
220 my $self = shift;
221 $self->blacklist('fcaco', $self->{name});
222 my $info = sprintf 'fcal controller %s in box %s/slot %s is %s',
223 $self->{name}, $self->{cpqFcaCntlrBoxIndex}, $self->{cpqFcaCntlrBoxIoSlot},
224 $self->{cpqFcaCntlrCondition};
225 if ($self->{cpqFcaCntlrCondition} eq 'other') {
226 if (1) { # was ist mit phys. drives?
227 $info .= ' needs attention';
228 $info .= sprintf(' (%s)', $self->{cpqFcaCntlrStatus}) unless $self->{cpqFcaCntlrStatus} eq 'ok';
229 $self->add_message(CRITICAL, $info);
230 $self->add_info($info);
231 } else {
232 $self->add_info($info);
233 $self->{blacklisted} = 1;
234 }
235 } elsif ($self->{cpqFcaCntlrCondition} ne 'ok') {
236 $info .= ' needs attention';
237 $info .= sprintf(' (%s)', $self->{cpqFcaCntlrStatus}) unless $self->{cpqFcaCntlrStatus} eq 'ok';
238 $self->add_message(CRITICAL, $info);
239 $self->add_info($info);
240 } else {
241 $self->add_info($info);
242 }
243 }
244
245 sub dump {
246 my $self = shift;
247 printf "[FCAL_CONTROLLER_%s]\n", $self->{name};
248 foreach (qw(cpqFcaCntlrBoxIndex cpqFcaCntlrBoxIoSlot cpqFcaCntlrModel
249 cpqFcaCntlrStatus cpqFcaCntlrCondition)) {
250 printf "%s: %s\n", $_, $self->{$_};
251 }
252 printf "\n";
253 }
254
255
256 package HP::Proliant::Component::DiskSubsystem::Fca::Accelerator;
257 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
258
259 use strict;
260 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
261
262 sub new {
263 my $class = shift;
264 my %params = @_;
265 my $self = {
266 runtime => $params{runtime},
267 blacklisted => 0,
268 info => undef,
269 extendedinfo => undef,
270 };
271 map { $self->{$_} = $params{$_} } grep /cpqFcaAccel/, keys %params;
272 $self->{name} = $params{name} ||
273 $self->{cpqFcaAccelBoxIndex}.':'.$self->{cpqFcaAccelBoxIoSlot};
274 $self->{controllerindex} = $self->{cpqFcaAccelBoxIndex};
275 bless $self, $class;
276 return $self;
277 }
278
279 sub check {
280 my $self = shift;
281 # !!! cpqFcaAccelStatus
282 $self->blacklist('fcaac', $self->{name});
283 my $info = sprintf 'fcal accelerator %s in box %s/slot %s is ',
284 $self->{name}, $self->{cpqFcaAccelBoxIndex}, $self->{cpqFcaAccelBoxIoSlot};
285 if ($self->{cpqFcaAccelStatus} eq 'invalid') {
286 $info .= 'not installed';
287 $self->add_info($info);
288 } elsif ($self->{cpqFcaAccelStatus} eq 'tmpDisabled') {
289 $info .= 'temp disabled';
290 $self->add_info($info);
291 } elsif ($self->{cpqFcaAccelCondition} eq 'other') {
292 $info .= sprintf '%s and needs attention (%s)',
293 $self->{cpqFcaAccelCondition}, $self->{cpqFcaAccelErrCode};
294 $self->add_message(CRITICAL, $info);
295 $self->add_info($info);
296 } elsif ($self->{cpqFcaAccelCondition} ne 'ok') {
297 $info .= sprintf '%s and needs attention (%s)',
298 $self->{cpqFcaAccelCondition}, $self->{cpqFcaAccelErrCode};
299 $self->add_message(CRITICAL, $info);
300 $self->add_info($info);
301 } else {
302 $info .= sprintf '%s', $self->{cpqFcaAccelCondition};
303 $self->add_info($info);
304 }
305 }
306
307 sub dump {
308 my $self = shift;
309 printf "[FCAL_ACCELERATOR_%s]\n", $self->{name};
310 foreach (qw(cpqFcaAccelBoxIndex cpqFcaAccelBoxIoSlot cpqFcaAccelStatus
311 cpqFcaAccelErrCode cpqFcaAccelBatteryStatus cpqFcaAccelCondition)) {
312 printf "%s: %s\n", $_, $self->{$_};
313 }
314 printf "\n";
315 }
316
317
318 package HP::Proliant::Component::DiskSubsystem::Fca::LogicalDrive;
319 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
320
321 use strict;
322 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
323
324 sub new {
325 my $class = shift;
326 my %params = @_;
327 my $self = {
328 runtime => $params{runtime},
329 blacklisted => 0,
330 info => undef,
331 extendedinfo => undef,
332 };
333 map { $self->{$_} = $params{$_} } grep /cpqFcaLogDrv/, keys %params;
334 bless $self, $class;
335 $self->{name} = $params{name} ||
336 $self->{cpqFcaLogDrvBoxIndex}.':'.
337 $self->{cpqFcaLogDrvIndex};
338 $self->{controllerindex} = $self->{cpqFcaLogDrvBoxIndex};
339 return $self;
340 }
341
342 sub check {
343 my $self = shift;
344 $self->blacklist('fcald', $self->{name});
345 my $info = sprintf 'logical drive %s (%s) is %s',
346 $self->{name}, $self->{cpqFcaLogDrvFaultTol}, $self->{cpqFcaLogDrvCondition};
347 if ($self->{cpqFcaLogDrvCondition} ne "ok") {
348 $info .= sprintf ' (%s)', $self->{cpqFcaLogDrvStatus};
349 if ($self->{cpqFcaLogDrvStatus} =~
350 /rebuild|recovering|expand/) {
351 $info .= sprintf ' (%s)', $self->{cpqFcaLogDrvStatus};
352 $self->add_message(WARNING, $info);
353 } else {
354 $self->add_message(CRITICAL, $info);
355 }
356 }
357 $self->add_info($info);
358 }
359
360 sub dump {
361 my $self = shift;
362 printf "[LOGICAL_DRIVE_%s]\n", $self->{name};
363 foreach (qw(cpqFcaLogDrvBoxIndex cpqFcaLogDrvIndex cpqFcaLogDrvFaultTol
364 cpqFcaLogDrvStatus cpqFcaLogDrvPercentRebuild cpqFcaLogDrvSize
365 cpqFcaLogDrvPhyDrvIDs cpqFcaLogDrvCondition)) {
366 printf "%s: %s\n", $_, $self->{$_};
367 }
368 printf "\n";
369 }
370
371
372 package HP::Proliant::Component::DiskSubsystem::Fca::PhysicalDrive;
373 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
374
375 use strict;
376 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
377
378 sub new {
379 my $class = shift;
380 my %params = @_;
381 my $self = {
382 runtime => $params{runtime},
383 blacklisted => 0,
384 info => undef,
385 extendedinfo => undef,
386 };
387 map { $self->{$_} = $params{$_} } grep /cpqFcaPhyDrv/, keys %params;
388 $self->{name} = $params{name} ||
389 $self->{cpqFcaPhyDrvBoxIndex}.':'.$self->{cpqFcaPhyDrvIndex}; ####vorerst
390 $self->{controllerindex} = $self->{cpqScsiPhyDrvCntlrIndex};
391 bless $self, $class;
392 return $self;
393 }
394
395 sub check {
396 my $self = shift;
397 $self->blacklist('fcapd', $self->{name});
398 my $info = sprintf "physical drive %s is %s",
399 $self->{name}, $self->{cpqFcaPhyDrvStatus};
400 if ($self->{cpqFcaPhyDrvStatus} eq 'unconfigured') {
401 # not part of a logical drive
402 # condition will surely be other
403 } elsif ($self->{cpqFcaPhyDrvCondition} ne 'ok') {
404 $self->add_message(CRITICAL, $info);
405 }
406 $self->add_info($info);
407 }
408
409 sub dump {
410 my $self = shift;
411 printf "[PHYSICAL_DRIVE_%s]\n", $self->{name};
412 foreach (qw(cpqFcaPhyDrvBoxIndex cpqFcaPhyDrvIndex cpqFcaPhyDrvModel
413 cpqFcaPhyDrvBay cpqFcaPhyDrvStatus cpqFcaPhyDrvCondition
414 cpqFcaPhyDrvSize cpqFcaPhyDrvBusNumber)) {
415 printf "%s: %s\n", $_, $self->{$_};
416 }
417 printf "\n";
418 }
419
420
421 package HP::Proliant::Component::DiskSubsystem::Fca::SpareDrive;
422 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Fca);
423
424 use strict;
425 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
426
427 sub dump {
428 my $self = shift;
429 printf "[SPARE_DRIVE]\n";
430 }
431
432
433 1;