Debian Codegraph @

src/centreon/common/aruba/snmp/mode/components/module.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 centreon::common::aruba::snmp::mode::components::module;
22
23 use strict;
24 use warnings;
25
26 my %map_card_type = (
27 1 => 'lc1',
28 2 => 'lc2',
29 3 => 'sc1',
30 4 => 'sc2',
31 5 => 'sw2400',
32 6 => 'sw800',
33 7 => 'sw200',
34 8 => 'm3mk1',
35 9 => 'sw3200',
36 10 => 'sw3400',
37 11 => 'sw3600',
38 12 => 'sw650',
39 13 => 'sw651',
40 14 => 'reserved1',
41 15 => 'reserved2',
42 16 => 'sw620',
43 17 => 'sw3500'
44 );
45 my %map_module_status = (
46 1 => 'active',
47 2 => 'inactive',
48 );
49
50 my $mapping = {
51 sysExtCardType => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1.2', map => \%map_card_type },
52 sysExtCardStatus => { oid => '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1.12', map => \%map_module_status },
53 };
54 my $oid_wlsxSysExtCardEntry = '.1.3.6.1.4.1.14823.2.2.1.2.1.16.1';
55
56 sub load {
57 my ($self) = @_;
58
59 push @{$self->{request}}, { oid => $oid_wlsxSysExtCardEntry };
60 }
61
62 sub check {
63 my ($self) = @_;
64
65 $self->{output}->output_add(long_msg => "Checking modules");
66 $self->{components}->{module} = {name => 'modules', total => 0, skip => 0};
67 return if ($self->check_filter(section => 'module'));
68
69 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_wlsxSysExtCardEntry}})) {
70 next if ($oid !~ /^$mapping->{sysExtCardStatus}->{oid}\.(.*)$/);
71 my $instance = $1;
72 my $result = $self->{snmp}->map_instance(
73 mapping => $mapping,
74 results => $self->{results}->{$oid_wlsxSysExtCardEntry},
75 instance => $instance
76 );
77
78 next if ($self->check_filter(section => 'module', instance => $instance));
79 $self->{components}->{module}->{total}++;
80
81 $self->{output}->output_add(
82 long_msg => sprintf("Module '%s/%s' status is %s [instance: %s].",
83 $result->{sysExtCardType}, $instance, $result->{sysExtCardStatus},
84 $instance
85 ));
86 my $exit = $self->get_severity(section => 'module', value => $result->{sysExtCardStatus});
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(
89 severity => $exit,
90 short_msg => sprintf("Module '%s/%s' status is %s",
91 $result->{sysExtCardType},
92 $instance,
93 $result->{sysExtCardStatus})
94 );
95 }
96 }
97 }
98
99 1;