| 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 os::picos::snmp::mode::components::psu; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_status = ( |
| 27 |
1 => 'power-on', |
| 28 |
2 => 'power-off' |
| 29 |
); |
| 30 |
|
| 31 |
my $mapping = { |
| 32 |
index => { oid => '.1.3.6.1.4.1.35098.1.11.1.1'}, |
| 33 |
status => { oid => '.1.3.6.1.4.1.35098.1.11.1.3', map => \%map_status }, |
| 34 |
speed => { oid => '.1.3.6.1.4.1.35098.1.11.1.5' }, |
| 35 |
temperature => { oid => '.1.3.6.1.4.1.35098.1.11.1.4' } |
| 36 |
}; |
| 37 |
|
| 38 |
my $oid_picaRpsuEntry = '.1.3.6.1.4.1.35098.1.11.1'; |
| 39 |
|
| 40 |
sub load {} |
| 41 |
|
| 42 |
sub check { |
| 43 |
my ($self) = @_; |
| 44 |
|
| 45 |
$self->{output}->output_add(long_msg => "Checking redundancy power supplies"); |
| 46 |
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; |
| 47 |
return if ($self->check_filter(section => 'psu')); |
| 48 |
|
| 49 |
my $snmp_result = $self->{snmp}->get_table( |
| 50 |
oid => '.1.3.6.1.4.1.35098.1.11', |
| 51 |
start => $oid_picaRpsuEntry |
| 52 |
); |
| 53 |
|
| 54 |
|
| 55 |
foreach my $oid (keys %{$snmp_result}) { |
| 56 |
next if ($oid !~ /^$mapping->{index}->{oid}\.(.*)$/); |
| 57 |
my $instance = $1; |
| 58 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); |
| 59 |
|
| 60 |
next if ($self->check_filter(section => 'psu', instance => $instance)); |
| 61 |
$self->{components}->{psu}->{total}++; |
| 62 |
|
| 63 |
my $celsius_fan_temp = $result->{temperature} =~ s/\s\C.*//r; |
| 64 |
|
| 65 |
$self->{output}->output_add( |
| 66 |
long_msg => sprintf( |
| 67 |
"power supply '%s' status is '%s' [instance: %s, fan speed: %s, temperature: %s]", |
| 68 |
$instance, $result->{status}, $instance, $result->{speed}, $celsius_fan_temp |
| 69 |
) |
| 70 |
); |
| 71 |
my $exit = $self->get_severity(section => 'psu', value => $result->{status}); |
| 72 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 73 |
$self->{output}->output_add( |
| 74 |
severity => $exit, |
| 75 |
short_msg => sprintf( |
| 76 |
"Power supply '%s' status is '%s'", $instance, $result->{status} |
| 77 |
) |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
if ($result->{speed} =~ /[0-9]/) { |
| 82 |
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.fanspeed', instance => $instance, value => $result->{speed}); |
| 83 |
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { |
| 84 |
$self->{output}->output_add( |
| 85 |
severity => $exit, |
| 86 |
short_msg => sprintf( |
| 87 |
"Power supply '%s' fan speed is %s rpm", $instance, $result->{speed} |
| 88 |
) |
| 89 |
); |
| 90 |
} |
| 91 |
|
| 92 |
$self->{output}->perfdata_add( |
| 93 |
nlabel => 'hardware.powersupply.fan.speed.rpm', |
| 94 |
unit => 'rpm', |
| 95 |
instances => $instance, |
| 96 |
value => $result->{speed}, |
| 97 |
min => 0 |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
if ($result->{temperature} =~ /[0-9]/) { |
| 102 |
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'psu.temperature', instance => $instance, value => $result->{temperature}); |
| 103 |
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { |
| 104 |
$self->{output}->output_add( |
| 105 |
severity => $exit, |
| 106 |
short_msg => sprintf( |
| 107 |
"Power supply '%s' temperature is %s C", $instance, $celsius_fan_temp |
| 108 |
) |
| 109 |
); |
| 110 |
} |
| 111 |
|
| 112 |
$self->{output}->perfdata_add( |
| 113 |
nlabel => 'hardware.powersupply.temperature.celsius', |
| 114 |
unit => 'C', |
| 115 |
instances => $instance, |
| 116 |
value => $celsius_fan_temp |
| 117 |
); |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
1; |