Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/controller.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::dell::openmanage::snmp::mode::components::controller;
22
23 use strict;
24 use warnings;
25
26 my %map_state = (
27 0 => 'unknown',
28 1 => 'ready',
29 2 => 'failed',
30 3 => 'online',
31 4 => 'offline',
32 6 => 'degraded',
33 );
34 my %map_status = (
35 1 => 'other',
36 2 => 'unknown',
37 3 => 'ok',
38 4 => 'nonCritical',
39 5 => 'critical',
40 6 => 'nonRecoverable',
41 );
42
43 # In MIB 'dcstorag.mib'
44 my $mapping = {
45 controllerName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.2' },
46 };
47 my $mapping2 = {
48 controllerComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.38', map => \%map_status },
49 };
50 my $mapping3 = {
51 controllerState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.5', map => \%map_state },
52 };
53 my $mapping4 = {
54 controllerFWVersion => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.1.1.8' },
55 };
56
57 sub load {
58 my ($self) = @_;
59
60 push @{$self->{request}}, { oid => $mapping->{controllerName}->{oid} }, { oid => $mapping2->{controllerComponentStatus}->{oid} },
61 { oid => $mapping3->{controllerState}->{oid} }, { oid => $mapping4->{controllerFWVersion}->{oid} };
62 }
63
64 sub check {
65 my ($self) = @_;
66
67 $self->{output}->output_add(long_msg => "Checking controllers");
68 $self->{components}->{controller} = {name => 'controllers', total => 0, skip => 0};
69 return if ($self->check_filter(section => 'controller'));
70
71 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping2->{controllerComponentStatus}->{oid}}})) {
72 next if ($oid !~ /^$mapping2->{controllerComponentStatus}->{oid}\.(.*)$/);
73 my $instance = $1;
74 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{controllerName}->{oid}}, instance => $instance);
75 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{controllerComponentStatus}->{oid}}, instance => $instance);
76 my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{controllerState}->{oid}}, instance => $instance);
77 my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{controllerFWVersion}->{oid}}, instance => $instance);
78
79 next if ($self->check_filter(section => 'controller', instance => $instance));
80
81 $self->{components}->{controller}->{total}++;
82
83 $self->{output}->output_add(long_msg => sprintf("Controller '%s' status is '%s' [instance: %s, state: %s, firmware: %s]",
84 $result->{controllerName}, $result2->{controllerComponentStatus}, $instance,
85 $result3->{controllerState}, $result4->{controllerFWVersion}
86 ));
87 my $exit = $self->get_severity(label => 'default', section => 'controller', value => $result2->{controllerComponentStatus});
88 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
89 $self->{output}->output_add(severity => $exit,
90 short_msg => sprintf("Controller '%s' status is '%s'",
91 $result->{controllerName}, $result2->{controllerComponentStatus}));
92 }
93 }
94 }
95
96 1;