Debian Codegraph @

src/network/extreme/snmp/mode/components/poe.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::extreme::snmp::mode::components::poe;
22
23 use strict;
24 use warnings;
25
26 my %map_poe_status = (
27 1 => 'initializing',
28 2 => 'operational',
29 3 => 'downloadFail',
30 4 => 'calibrationRequired',
31 5 => 'invalidFirmware',
32 6 => 'mismatchVersion',
33 7 => 'updating',
34 8 => 'invalidDevice',
35 9 => 'notOperational',
36 10 => 'other',
37 );
38
39 my $mapping = {
40 extremePethSlotPoeStatus => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.8', map => \%map_poe_status },
41 };
42 my $mapping2 = {
43 extremePethSlotMeasuredPower => { oid => '.1.3.6.1.4.1.1916.1.27.1.2.1.14' },
44 };
45
46 sub load {
47 my ($self) = @_;
48
49 push @{$self->{request}}, { oid => $mapping->{extremePethSlotPoeStatus}->{oid} },
50 { oid => $mapping2->{extremePethSlotMeasuredPower}->{oid} };
51 }
52
53 sub check {
54 my ($self) = @_;
55
56 $self->{output}->output_add(long_msg => "Checking poes");
57 $self->{components}->{poe} = { name => 'poes', total => 0, skip => 0 };
58 return if ($self->check_filter(section => 'poe'));
59
60 my ($exit, $warn, $crit, $checked);
61 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}})) {
62 $oid =~ /^$mapping->{extremePethSlotPoeStatus}->{oid}\.(.*)$/;
63 my $instance = $1;
64 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{extremePethSlotPoeStatus}->{oid}}, instance => $instance);
65 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{extremePethSlotMeasuredPower}->{oid}}, instance => $instance);
66
67 next if ($self->check_filter(section => 'poe', instance => $instance));
68
69 $result2->{extremePethSlotMeasuredPower} = defined($result2->{extremePethSlotMeasuredPower}) && $result2->{extremePethSlotMeasuredPower} =~ /\d+/ ?
70 sprintf("%.3f", $result2->{extremePethSlotMeasuredPower} / 1000) : 'unknown';
71
72 $self->{components}->{poe}->{total}++;
73 $self->{output}->output_add(
74 long_msg => sprintf(
75 "Poe '%s' status is '%s' [instance = %s, power = %s]",
76 $instance,
77 $result->{extremePethSlotPoeStatus},
78 $instance,
79 $result2->{extremePethSlotMeasuredPower}
80 )
81 );
82 $exit = $self->get_severity(section => 'poe', value => $result->{extremePethSlotPoeStatus});
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 "Poe '%s' status is '%s'",
88 $instance,
89 $result->{extremePethSlotPoeStatus}
90 )
91 );
92 }
93
94 next if ($result2->{extremePethSlotMeasuredPower} !~ /\d+/);
95
96 ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'poe', instance => $instance, value => $result2->{extremePethSlotMeasuredPower});
97 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
98 $self->{output}->output_add(
99 severity => $exit,
100 short_msg => sprintf(
101 "Poe '%s' is '%s' W",
102 $instance,
103 $result2->{extremePethSlotMeasuredPower}
104 )
105 );
106 }
107 $self->{output}->perfdata_add(
108 label => 'poe_power', unit => 'W',
109 nlabel => 'hardware.poe.power.watt',
110 instances => $instance,
111 value => $result2->{extremePethSlotMeasuredPower},
112 warning => $warn,
113 critical => $crit,
114 min => 0
115 );
116 }
117 }
118
119 1;