Debian Codegraph @

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