Debian Codegraph @

src/network/extreme/snmp/mode/components/slot.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 network::extreme::snmp::mode::components::slot;
22
23 use strict;
24 use warnings;
25
26 my %map_slot_status = (
27 1 => 'notPresent',
28 2 => 'testing',
29 3 => 'mismatch',
30 4 => 'failed',
31 5 => 'operational',
32 6 => 'powerdown',
33 7 => 'unknown',
34 8 => 'present',
35 9 => 'poweron',
36 10 => 'post',
37 11 => 'downloading',
38 12 => 'booting',
39 13 => 'offline',
40 14 => 'initializing',
41 100 => 'invalid',
42 );
43
44 my $mapping = {
45 extremeSlotName => { oid => '.1.3.6.1.4.1.1916.1.1.2.2.1.2' },
46 extremeSlotModuleState => { oid => '.1.3.6.1.4.1.1916.1.1.2.2.1.5', map => \%map_slot_status },
47 };
48 my $oid_extremeSlotEntry = '.1.3.6.1.4.1.1916.1.1.2.2.1';
49
50 sub load {
51 my ($self) = @_;
52
53 push @{$self->{request}}, { oid => $oid_extremeSlotEntry, start => $mapping->{extremeSlotName}->{oid}, end => $mapping->{extremeSlotModuleState}->{oid} };
54 }
55
56 sub check {
57 my ($self) = @_;
58
59 $self->{output}->output_add(long_msg => "Checking slots");
60 $self->{components}->{slot} = { name => 'slots', total => 0, skip => 0 };
61 return if ($self->check_filter(section => 'slot'));
62
63 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_extremeSlotEntry}})) {
64 next if ($oid !~ /^$mapping->{extremeSlotModuleState}->{oid}\.(.*)$/);
65 my $instance = $1;
66 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_extremeSlotEntry}, instance => $instance);
67
68 next if ($self->check_filter(section => 'slot', instance => $instance));
69 if ($result->{extremeSlotModuleState} =~ /notPresent/i) {
70 $self->absent_problem(section => 'slot', instance => $instance);
71 next;
72 }
73
74 $self->{components}->{slot}->{total}++;
75 $self->{output}->output_add(long_msg =>
76 sprintf(
77 "Slot '%s' status is '%s' [instance = %s]",
78 $result->{extremeSlotName},
79 $result->{extremeSlotModuleState},
80 $instance
81 )
82 );
83 my $exit = $self->get_severity(section => 'slot', value => $result->{extremeSlotModuleState});
84 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
85 $self->{output}->output_add(
86 severity => $exit,
87 short_msg => sprintf(
88 "Slot '%s' status is '%s'",
89 $result->{extremeSlotName},
90 $result->{extremeSlotModuleState}
91 )
92 );
93 }
94 }
95 }
96
97 1;