Debian Codegraph @

src/storage/emc/datadomain/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 storage::emc::datadomain::snmp::mode::components::psu;
22
23 use strict;
24 use warnings;
25
26 my %map_psu_status = ();
27 my ($oid_powerModuleDescription, $oid_powerModuleStatus);
28 my $oid_powerModuleEntry = '.1.3.6.1.4.1.19746.1.1.1.1.1.1';
29
30 sub load {
31 my ($self) = @_;
32
33 push @{$self->{request}}, { oid => $oid_powerModuleEntry };
34 }
35
36 sub check {
37 my ($self) = @_;
38
39 $self->{output}->output_add(long_msg => "Checking power supplies");
40 $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
41 return if ($self->check_filter(section => 'psu'));
42
43 if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) {
44 $oid_powerModuleDescription = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.3';
45 $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4';
46 %map_psu_status = (
47 0 => 'absent', 1 => 'ok', 2 => 'failed', 3 => 'faulty', 4 => 'acnone',
48 99 => 'unknown'
49 );
50 } else {
51 $oid_powerModuleDescription = ''; # none
52 $oid_powerModuleStatus = '.1.3.6.1.4.1.19746.1.1.1.1.1.1.4';
53 %map_psu_status = (1 => 'ok', 2 => 'unknown', 3 => 'failed');
54 }
55
56 foreach my $oid (keys %{$self->{results}->{$oid_powerModuleEntry}}) {
57 next if ($oid !~ /^$oid_powerModuleStatus\.(.*)$/);
58 my $instance = $1;
59 my $psu_descr = defined($self->{results}->{$oid_powerModuleEntry}->{$oid_powerModuleDescription . '.' . $instance}) ?
60 centreon::plugins::misc::trim($self->{results}->{$oid_powerModuleEntry}->{$oid_powerModuleDescription . '.' . $instance}) : 'unknown';
61 my $psu_status = defined($map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}}) ?
62 $map_psu_status{$self->{results}->{$oid_powerModuleEntry}->{$oid}} : 'unknown';
63
64 next if ($self->check_filter(section => 'psu', instance => $instance));
65 next if ($psu_status =~ /absent/i &&
66 $self->absent_problem(section => 'psu', instance => $instance));
67
68 $self->{components}->{psu}->{total}++;
69 $self->{output}->output_add(
70 long_msg => sprintf(
71 "power Supply '%s' status is '%s' [description: %s]",
72 $instance, $psu_status, $instance
73 )
74 );
75
76 my $exit = $self->get_severity(section => 'psu', value => $psu_status);
77 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
78 $self->{output}->output_add(
79 severity => $exit,
80 short_msg => sprintf("Power Supply '%s' status is '%s'", $instance, $psu_status)
81 );
82 }
83 }
84 }
85
86 1;