Debian Codegraph @

src/centreon/common/force10/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::force10::snmp::mode::components::fan;
22
23 use strict;
24 use warnings;
25
26 my $map_status = {
27 1 => 'up',
28 2 => 'down',
29 3 => 'absent'
30 };
31
32 my $mapping = {
33 sseries => {
34 status => { oid => '.1.3.6.1.4.1.6027.3.10.1.2.4.1.2', map => $map_status } # chSysFanTrayOperStatus
35 },
36 mseries => {
37 status => { oid => '.1.3.6.1.4.1.6027.3.19.1.2.3.1.2', map => $map_status } # chSysFanTrayOperStatus
38 },
39 zseries => {
40 status => { oid => '.1.3.6.1.4.1.6027.3.25.1.2.7.1.2', map => $map_status } # chSysFanTrayOperStatus
41 },
42 os9 => {
43 status => { oid => '.1.3.6.1.4.1.6027.3.26.1.4.7.1.4', map => $map_status } # dellNetFanTrayOperStatus
44 }
45 };
46
47 sub load {
48 my ($self) = @_;
49
50 push @{$self->{request}},
51 { oid => $mapping->{sseries}->{status}->{oid} },
52 { oid => $mapping->{mseries}->{status}->{oid} },
53 { oid => $mapping->{zseries}->{status}->{oid} },
54 { oid => $mapping->{os9}->{status}->{oid} };
55 }
56
57 sub check {
58 my ($self) = @_;
59
60 $self->{output}->output_add(long_msg => 'Checking fans');
61 $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
62 return if ($self->check_filter(section => 'fan'));
63
64 foreach my $name (keys %$mapping) {
65 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{$name}->{status}->{oid} }})) {
66 next if ($oid !~ /^$mapping->{$name}->{status}->{oid}\.(.*)$/);
67 my $instance = $1;
68 my $result = $self->{snmp}->map_instance(mapping => $mapping->{$name}, results => $self->{results}->{ $mapping->{$name}->{status}->{oid} }, instance => $instance);
69
70 next if ($result->{status} =~ /absent/i &&
71 $self->absent_problem(section => 'fan', instance => $instance));
72 next if ($self->check_filter(section => 'fan', instance => $instance));
73 $self->{components}->{fan}->{total}++;
74
75 $self->{output}->output_add(
76 long_msg => sprintf(
77 "fan '%s' status is '%s' [instance: %s]",
78 $instance, $result->{status},
79 $instance
80 )
81 );
82 my $exit = $self->get_severity(section => 'fan', value => $result->{status});
83 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
84 $self->{output}->output_add(
85 severity => $exit,
86 short_msg => sprintf(
87 "Fan '%s' status is '%s'",
88 $instance, $result->{status}
89 )
90 );
91 }
92 }
93 }
94 }
95
96 1;