Debian Codegraph @

src/hardware/devices/aeg/acm/snmp/mode/components/multiple.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::devices::aeg::acm::snmp::mode::components::multiple;
22
23 use strict;
24 use warnings;
25
26 my %map_status_1000 = (0 => 'false', 1 => 'true');
27
28 my $mapping_acm1000 = {
29 label => { oid => '.1.3.6.1.4.1.15416.37.8.2.1.2' },
30 active => { oid => '.1.3.6.1.4.1.15416.37.8.2.1.3', map => \%map_status_1000 },
31 };
32 my $mapping_acmi1000 = {
33 label => { oid => '.1.3.6.1.4.1.15416.38.8.2.1.2' },
34 active => { oid => '.1.3.6.1.4.1.15416.38.8.2.1.3', map => \%map_status_1000 },
35 };
36
37 my $oid_multAlarmTableEntryAcm1000 = '.1.3.6.1.4.1.15416.37.8.2.1';
38 my $oid_multAlarmTableEntryAcmi1000 = '.1.3.6.1.4.1.15416.38.8.2.1';
39
40 sub load {
41 my ($self) = @_;
42
43 push @{$self->{request}}, { oid => $oid_multAlarmTableEntryAcm1000 },
44 { oid => $oid_multAlarmTableEntryAcmi1000 };
45 }
46
47 sub check_alarms {
48 my ($self, %options) = @_;
49
50 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
51 next if ($oid !~ /^$options{mapping}->{label}->{oid}\.(.*)$/);
52 my $instance = $1;
53 my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
54
55 next if (centreon::plugins::misc::trim($result->{label}) eq '');
56 next if ($self->check_filter(section => 'multiple', instance => $instance));
57 $self->{components}->{multiple}->{total}++;
58
59 $self->{output}->output_add(long_msg => sprintf("Multiple alarm '%s' status is '%s' [instance = %s]",
60 centreon::plugins::misc::trim($result->{label}),
61 $result->{active}, $instance));
62
63 my $exit = $self->get_severity(section => 'multiple', instance => $instance, value => $result->{active});
64 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
65 $self->{output}->output_add(severity => $exit,
66 short_msg => sprintf("Multiple alarm '%s' status is '%s'", centreon::plugins::misc::trim($result->{label}), $result->{active}));
67 }
68 }
69 }
70
71 sub check {
72 my ($self) = @_;
73
74 $self->{output}->output_add(long_msg => "Checking multiple alarms");
75 $self->{components}->{multiple} = {name => 'multiple alarms', total => 0, skip => 0};
76 return if ($self->check_filter(section => 'multiple'));
77
78 check_alarms($self, entry => $oid_multAlarmTableEntryAcm1000, mapping => $mapping_acm1000);
79 check_alarms($self, entry => $oid_multAlarmTableEntryAcmi1000, mapping => $mapping_acmi1000);
80 }
81
82 1;