Debian Codegraph @

src/hardware/server/xfusion/ibmc/snmp/mode/components/raidcontroller.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package hardware::server::xfusion::ibmc::snmp::mode::components::raidcontroller;
22
23 use strict;
24 use warnings;
25
26 my $mapping = {
27 raidControllerComponentName => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1.4' },
28 raidControllerHealthStatus => { oid => '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1.7' }
29 };
30 my $oid_raidControllerDescriptionEntry = '.1.3.6.1.4.1.58132.2.235.1.1.36.50.1';
31
32 sub load {
33 my ($self) = @_;
34
35 push @{$self->{request}}, {
36 oid => $oid_raidControllerDescriptionEntry,
37 start => $mapping->{raidControllerComponentName}->{oid},
38 end => $mapping->{raidControllerHealthStatus}->{oid},
39 };
40 }
41
42 sub check {
43 my ($self) = @_;
44
45 $self->{output}->output_add(long_msg => "Checking raid controllers");
46 $self->{components}->{raidcontroller} = {name => 'raidcontrollers', total => 0, skip => 0};
47 return if ($self->check_filter(section => 'raidcontroller'));
48
49 my %bitmap_status = (
50 0 => 'memory correctable error',
51 1 => 'memory uncorrectable error',
52 2 => 'memory ECC error reached limit',
53 3 => 'NVRAM uncorrectable error',
54 );
55 my %map_status = (
56 0 => 'ok',
57 65535 => 'unknown',
58 );
59
60 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raidControllerDescriptionEntry}})) {
61 next if ($oid !~ /^$mapping->{raidControllerHealthStatus}->{oid}\.(.*)$/);
62 my $instance = $1;
63 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raidControllerDescriptionEntry}, instance => $instance);
64
65 next if ($self->check_filter(section => 'raidcontroller', instance => $instance));
66 $self->{components}->{raidcontroller}->{total}++;
67
68 if (defined($map_status{$result->{raidControllerHealthStatus}})) {
69 $self->{output}->output_add(
70 long_msg => sprintf(
71 "raid controller '%s' status is '%s' [instance: %s]",
72 $result->{raidControllerComponentName}, $map_status{$result->{raidControllerHealthStatus}}, $instance,
73 )
74 );
75
76 my $exit = $self->get_severity(section => 'raidcontroller', value => $map_status{$result->{raidControllerHealthStatus}});
77 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
78 $self->{output}->output_add(
79 severity => $exit,
80 short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{raidControllerComponentName}, $map_status{$result->{raidControllerHealthStatus}})
81 );
82 }
83
84 next;
85 }
86
87 for (my $i = 0; $i < 4; $i++) {
88 next if (!($result->{raidControllerHealthStatus} & (1 << $i)));
89
90 my $status = $bitmap_status{$i};
91 $self->{output}->output_add(
92 long_msg => sprintf(
93 "raid controller '%s' status is '%s' [instance: %s]",
94 $result->{raidControllerComponentName}, $status, $instance,
95 )
96 );
97
98 my $exit = $self->get_severity(section => 'raidcontroller', value => $status);
99 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
100 $self->{output}->output_add(
101 severity => $exit,
102 short_msg => sprintf("Raid controller '%s' status is '%s'", $result->{raidControllerComponentName}, $status)
103 );
104 }
105 }
106 }
107 }
108
109 1;