| 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::ibm::fs900::snmp::mode::components::psu; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_psu_state = ( |
| 27 |
0 => 'success', |
| 28 |
1 => 'error', |
| 29 |
); |
| 30 |
|
| 31 |
# In MIB 'IBM-FLASHSYSTEM.MIB' |
| 32 |
my $mapping = { |
| 33 |
psuObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.2' }, |
| 34 |
psuCommErr => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.3', map => \%map_psu_state }, |
| 35 |
psuACGood => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.4', map => \%map_psu_state }, |
| 36 |
psuDCGood => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.5', map => \%map_psu_state }, |
| 37 |
psuFan => { oid => '.1.3.6.1.4.1.2.6.255.1.1.5.10.1.6' }, |
| 38 |
}; |
| 39 |
my $oid_powerTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.5.10.1'; |
| 40 |
|
| 41 |
sub load { |
| 42 |
my ($self) = @_; |
| 43 |
|
| 44 |
push @{$self->{request}}, { oid => $oid_powerTableEntry }; |
| 45 |
} |
| 46 |
|
| 47 |
sub check { |
| 48 |
my ($self) = @_; |
| 49 |
|
| 50 |
$self->{output}->output_add(long_msg => "Checking psu"); |
| 51 |
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; |
| 52 |
return if ($self->check_filter(section => 'psu')); |
| 53 |
|
| 54 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerTableEntry}})) { |
| 55 |
next if ($oid !~ /^$mapping->{psuObject}->{oid}\.(.*)$/); |
| 56 |
my $instance = $1; |
| 57 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_powerTableEntry}, instance => $instance); |
| 58 |
|
| 59 |
next if ($self->check_filter(section => 'psu', instance => $instance)); |
| 60 |
|
| 61 |
$self->{components}->{psu}->{total}++; |
| 62 |
$self->{output}->output_add(long_msg => sprintf("Psu '%s' [instance = %s, communications = %s, AC = %s, DC = %s, fan = %s rpm]", |
| 63 |
$result->{psuObject}, $instance, $result->{psuCommErr}, $result->{psuACGood}, $result->{psuDCGood}, $result->{psuFan})); |
| 64 |
|
| 65 |
my $exit = $self->get_severity(section => 'psu', value => $result->{psuCommErr}); |
| 66 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 67 |
$self->{output}->output_add(severity => $exit, |
| 68 |
short_msg => sprintf("Psu '%s' communications state is %s", |
| 69 |
$instance, $result->{psuCommErr})); |
| 70 |
} |
| 71 |
|
| 72 |
$exit = $self->get_severity(section => 'psu', value => $result->{psuACGood}); |
| 73 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 74 |
$self->{output}->output_add(severity => $exit, |
| 75 |
short_msg => sprintf("Psu '%s' AC state is %s", |
| 76 |
$instance, $result->{psuACGood})); |
| 77 |
} |
| 78 |
|
| 79 |
$exit = $self->get_severity(section => 'psu', value => $result->{psuDCGood}); |
| 80 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 81 |
$self->{output}->output_add(severity => $exit, |
| 82 |
short_msg => sprintf("Psu '%s' DC state is %s", |
| 83 |
$instance, $result->{psuDCGood})); |
| 84 |
} |
| 85 |
|
| 86 |
if (defined($result->{psuFan}) && $result->{psuFan} =~ /[0-9]/) { |
| 87 |
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fan', instance => $instance, value => $result->{psuFan}); |
| 88 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 89 |
$self->{output}->output_add(severity => $exit, |
| 90 |
short_msg => sprintf("Psu '%s' fan speed is %s rpm", $instance, $result->{psuFan})); |
| 91 |
} |
| 92 |
$self->{output}->perfdata_add( |
| 93 |
label => 'psu_fan', unit => 'rpm', |
| 94 |
nlabel => 'hardware.psu.fan.speed.rpm', |
| 95 |
instances => $instance, |
| 96 |
value => $result->{psuFan}, |
| 97 |
warning => $warn, |
| 98 |
critical => $crit, |
| 99 |
min => 0, |
| 100 |
); |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
1; |