Debian Codegraph @

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