Debian Codegraph @

src/network/nortel/standard/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 network::nortel::standard::snmp::mode::components::fan;
22
23 use strict;
24 use warnings;
25 use network::nortel::standard::snmp::mode::components::resources qw($map_fan_status);
26
27 my $mapping_rc = {
28 status => { oid => '.1.3.6.1.4.1.2272.1.4.7.1.1.2', map => $map_fan_status }, # rcChasFanOperStatus
29 temperature => { oid => '.1.3.6.1.4.1.2272.1.4.7.1.1.3' } # rcChasFanAmbientTemperature
30 };
31 my $oid_rcFanEntry = '.1.3.6.1.4.1.2272.1.4.7.1.1'; # rcChasFanEntry
32
33 my $mapping_voss = {
34 description => { oid => '.1.3.6.1.4.1.2272.1.101.1.1.4.1.3' }, # rcVossSystemFanInfoDescription
35 status => { oid => '.1.3.6.1.4.1.2272.1.101.1.1.4.1.4', map => $map_fan_status }, # rcVossSystemFanInfoOperStatus
36 };
37 my $oid_vossFanEntry = '.1.3.6.1.4.1.2272.1.101.1.1.4.1'; # rcVossSystemFanInfoEntry
38
39 sub load {
40 my ($self) = @_;
41
42 push @{$self->{request}},
43 { oid => $oid_rcFanEntry, end => $mapping_rc->{temperature}->{oid} },
44 { oid => $oid_vossFanEntry, start => $mapping_voss->{description}->{oid}, end => $mapping_voss->{status}->{oid} };
45 }
46
47 sub check_fan_rc {
48 my ($self) = @_;
49
50 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rcFanEntry}})) {
51 next if ($oid !~ /^$mapping_rc->{status}->{oid}\.(.*)$/);
52 my $instance = $1;
53 my $result = $self->{snmp}->map_instance(mapping => $mapping_rc, results => $self->{results}->{$oid_rcFanEntry}, instance => $instance);
54
55 next if ($self->check_filter(section => 'fan', instance => $instance));
56 $self->{components}->{fan}->{total}++;
57
58 $self->{output}->output_add(
59 long_msg => sprintf(
60 "fan '%s' status is '%s' [instance: %s, value: %s]",
61 $instance,
62 $result->{status},
63 $instance,
64 $result->{temperature}
65 )
66 );
67 my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{status});
68 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
69 $self->{output}->output_add(
70 severity => $exit,
71 short_msg => sprintf(
72 "Fan '%s' status is '%s'",
73 $instance, $result->{status}
74 )
75 );
76 }
77
78 my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.temperature', instance => $instance, value => $result->{temperature});
79 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
80 $self->{output}->output_add(
81 severity => $exit2,
82 short_msg => sprintf("Fan '%s' temperature is %s degree centigrade", $instance, $result->{temperature})
83 );
84 }
85 $self->{output}->perfdata_add(
86 nlabel => 'hardware.fan.temperature.celsius',
87 unit => 'C',
88 instances => $instance,
89 value => $result->{temperature},
90 warning => $warn,
91 critical => $crit
92 );
93 }
94 }
95
96 sub check_fan_voss {
97 my ($self) = @_;
98
99 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vossFanEntry}})) {
100 next if ($oid !~ /^$mapping_voss->{status}->{oid}\.(.*)$/);
101 my $instance = $1;
102 my $result = $self->{snmp}->map_instance(mapping => $mapping_voss, results => $self->{results}->{$oid_vossFanEntry}, instance => $instance);
103
104 next if ($self->check_filter(section => 'fan', instance => $instance));
105 $self->{components}->{fan}->{total}++;
106
107 $self->{output}->output_add(
108 long_msg => sprintf(
109 "%s status is '%s' [instance: %s]",
110 $result->{description},
111 $result->{status},
112 $instance
113 )
114 );
115 my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{status});
116 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
117 $self->{output}->output_add(
118 severity => $exit,
119 short_msg => sprintf(
120 "%s status is '%s'",
121 $result->{description}, $result->{status}
122 )
123 );
124 }
125 }
126 }
127
128 sub check {
129 my ($self) = @_;
130
131 $self->{output}->output_add(long_msg => 'Checking fans');
132 $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
133 return if ($self->check_filter(section => 'fan'));
134
135 check_fan_rc($self);
136 check_fan_voss($self);
137 }
138
139 1;