Debian Codegraph @

src/centreon/common/cisco/standard/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::cisco::standard::snmp::mode::components::module;
22
23 use strict;
24 use warnings;
25
26 my %map_module_state = (
27 1 => 'unknown',
28 2 => 'ok',
29 3 => 'disabled',
30 4 => 'okButDiagFailed',
31 5 => 'boot',
32 6 => 'selfTest',
33 7 => 'failed',
34 8 => 'missing',
35 9 => 'mismatchWithParent',
36 10 => 'mismatchConfig',
37 11 => 'diagFailed',
38 12 => 'dormant',
39 13 => 'outOfServiceAdmin',
40 14 => 'outOfServiceEnvTemp',
41 15 => 'poweredDown',
42 16 => 'poweredUp',
43 17 => 'powerDenied',
44 18 => 'powerCycled',
45 19 => 'okButPowerOverWarning',
46 20 => 'okButPowerOverCritical',
47 21 => 'syncInProgress',
48 22 => 'upgrading',
49 23 => 'okButAuthFailed',
50 24 => 'mdr',
51 25 => 'fwMismatchFound',
52 26 => 'fwDownloadSuccess',
53 27 => 'fwDownloadFailure'
54 );
55
56 # In MIB 'CISCO-ENTITY-FRU-CONTROL-MIB'
57 my $mapping = {
58 cefcModuleOperStatus => { oid => '.1.3.6.1.4.1.9.9.117.1.2.1.1.2', map => \%map_module_state }
59 };
60 my $oid_cefcModuleOperStatus = '.1.3.6.1.4.1.9.9.117.1.2.1.1.2';
61
62 sub load {
63 my ($self) = @_;
64
65 push @{$self->{request}}, { oid => $oid_cefcModuleOperStatus };
66 }
67
68 sub check {
69 my ($self) = @_;
70
71 $self->{output}->output_add(long_msg => "Checking modules");
72 $self->{components}->{module} = {name => 'modules', total => 0, skip => 0};
73 return if ($self->check_filter(section => 'module'));
74
75 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cefcModuleOperStatus}})) {
76 $oid =~ /\.([0-9]+)$/;
77 my $instance = $1;
78 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance);
79 my $module_descr = defined($self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $instance }) ?
80 $self->{results}->{ $self->{physical_name} }->{ $self->{physical_name} . '.' . $instance } : 'n/a';
81
82 next if ($self->check_filter(section => 'module', instance => $instance, name => $module_descr));
83
84 $self->{components}->{module}->{total}++;
85 $self->{output}->output_add(
86 long_msg => sprintf(
87 "module '%s' status is %s [instance: %s]",
88 $module_descr, $result->{cefcModuleOperStatus}, $instance
89 )
90 );
91 my $exit = $self->get_severity(section => 'module', instance => $instance, value => $result->{cefcModuleOperStatus});
92 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
93 $self->{output}->output_add(
94 severity => $exit,
95 short_msg => sprintf(
96 "Module '%s/%s' status is %s",
97 $module_descr, $instance, $result->{cefcModuleOperStatus}
98 )
99 );
100 }
101 }
102 }
103
104 1;