Debian Codegraph @

src/centreon/common/radlan/snmp/mode/components/fan.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::radlan::snmp::mode::components::fan;
22
23 use strict;
24 use warnings;
25 use centreon::common::radlan::snmp::mode::components::resources qw(
26 $rl_envmon_state
27 $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable
28 $oid_rlPhdUnitEnvParamEntry
29 );
30
31 my $mapping_stack = {
32 new => {
33 rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state },
34 rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state },
35 rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state },
36 rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state },
37 rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state },
38 rlPhdUnitEnvParamFan6Status => { oid => '.1.3.6.1.4.1.89.53.15.1.9', map => $rl_envmon_state }
39 },
40 old => {
41 rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state },
42 rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state },
43 rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state },
44 rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state },
45 rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state }
46 }
47 };
48
49 sub load {
50 my ($self) = @_;
51 }
52
53 sub check_fan_stack {
54 my ($self) = @_;
55
56 my $num_fans = 5;
57 $num_fans = 6 if ($self->{radlan_new} == 1);
58
59 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) {
60 next if ($oid !~ /^$mapping_stack->{new}->{rlPhdUnitEnvParamFan1Status}->{oid}\.(.*)$/);
61 my $instance = $1;
62 my $result = $self->{snmp}->map_instance(
63 mapping => $self->{radlan_new} == 1 ? $mapping_stack->{new} : $mapping_stack->{old},
64 results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry},
65 instance => $instance
66 );
67
68 for (my $i = 1; $i <= $num_fans; $i++) {
69 my $instance2 = 'stack.' . $instance . '.fan.' . $i;
70 my $name = 'rlPhdUnitEnvParamFan' . $i . 'Status';
71
72 next if ($self->check_filter(section => 'fan', instance => $instance2));
73 next if ($result->{$name} =~ /notPresent/i &&
74 $self->absent_problem(section => 'fan', instance => $instance2));
75
76 $self->{components}->{fan}->{total}++;
77 $self->{output}->output_add(
78 long_msg => sprintf(
79 "fan '%s' status is '%s' [instance: %s]",
80 $instance2,
81 $result->{$name},
82 $instance2
83 )
84 );
85
86 my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{$name});
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(
89 severity => $exit,
90 short_msg => sprintf(
91 "Fan '%s' status is '%s'",
92 $instance2,
93 $result->{$name}
94 )
95 );
96 }
97 }
98 }
99 }
100
101 sub check {
102 my ($self) = @_;
103
104 $self->{output}->output_add(long_msg => "Checking fans");
105 $self->{components}->{fan} = { name => 'fan', total => 0, skip => 0 };
106 return if ($self->check_filter(section => 'fan'));
107
108 check_fan_stack($self);
109 }
110
111 1;