| 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 hardware::server::hp::proliant::snmp::mode::components::temperature; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_temperature_condition = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'ok', |
| 29 |
3 => 'degraded', |
| 30 |
4 => 'failed', |
| 31 |
); |
| 32 |
my %map_location = ( |
| 33 |
1 => "other", |
| 34 |
2 => "unknown", |
| 35 |
3 => "system", |
| 36 |
4 => "systemBoard", |
| 37 |
5 => "ioBoard", |
| 38 |
6 => "cpu", |
| 39 |
7 => "memory", |
| 40 |
8 => "storage", |
| 41 |
9 => "removableMedia", |
| 42 |
10 => "powerSupply", |
| 43 |
11 => "ambient", |
| 44 |
12 => "chassis", |
| 45 |
13 => "bridgeCard", |
| 46 |
14 => "managementBoard", |
| 47 |
15 => "backplane", |
| 48 |
16 => "networkSlot", |
| 49 |
17 => "bladeSlot", |
| 50 |
18 => "virtual", |
| 51 |
); |
| 52 |
|
| 53 |
# In MIB 'CPQSTDEQ-MIB.mib' |
| 54 |
my $mapping = { |
| 55 |
cpqHeTemperatureLocale => { oid => '.1.3.6.1.4.1.232.6.2.6.8.1.3', map => \%map_location }, |
| 56 |
cpqHeTemperatureCelsius => { oid => '.1.3.6.1.4.1.232.6.2.6.8.1.4' }, |
| 57 |
cpqHeTemperatureThreshold => { oid => '.1.3.6.1.4.1.232.6.2.6.8.1.5' }, |
| 58 |
cpqHeTemperatureCondition => { oid => '.1.3.6.1.4.1.232.6.2.6.8.1.6', map => \%map_temperature_condition }, |
| 59 |
}; |
| 60 |
my $oid_cpqHeTemperatureEntry = '.1.3.6.1.4.1.232.6.2.6.8.1'; |
| 61 |
|
| 62 |
sub load { |
| 63 |
my ($self) = @_; |
| 64 |
|
| 65 |
push @{$self->{request}}, { oid => $oid_cpqHeTemperatureEntry, start => $mapping->{cpqHeTemperatureLocale}->{oid}, end => $mapping->{cpqHeTemperatureCondition}->{oid} }; |
| 66 |
} |
| 67 |
|
| 68 |
sub check { |
| 69 |
my ($self) = @_; |
| 70 |
|
| 71 |
$self->{output}->output_add(long_msg => "Checking temperatures"); |
| 72 |
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; |
| 73 |
return if ($self->check_filter(section => 'temperature')); |
| 74 |
|
| 75 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqHeTemperatureEntry}})) { |
| 76 |
next if ($oid !~ /^$mapping->{cpqHeTemperatureCondition}->{oid}\.(.*)$/); |
| 77 |
my $instance = $1; |
| 78 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqHeTemperatureEntry}, instance => $instance); |
| 79 |
|
| 80 |
next if ($self->check_filter(section => 'temperature', instance => $instance)); |
| 81 |
$self->{components}->{temperature}->{total}++; |
| 82 |
|
| 83 |
$self->{output}->output_add(long_msg => sprintf("'%s' %s temperature is %dC (%d max) (status is %s).", |
| 84 |
$instance, $result->{cpqHeTemperatureLocale}, $result->{cpqHeTemperatureCelsius}, |
| 85 |
$result->{cpqHeTemperatureThreshold}, |
| 86 |
$result->{cpqHeTemperatureCondition})); |
| 87 |
my $exit = $self->get_severity(section => 'temperature', value => $result->{cpqHeTemperatureCondition}); |
| 88 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 89 |
$self->{output}->output_add(severity => $exit, |
| 90 |
short_msg => sprintf("temperature '%s' %s status is %s", |
| 91 |
$instance, $result->{cpqHeTemperatureLocale}, $result->{cpqHeTemperatureCondition})); |
| 92 |
} |
| 93 |
|
| 94 |
if (defined($result->{cpqHeTemperatureCelsius}) && $result->{cpqHeTemperatureCelsius} != -1) { |
| 95 |
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{cpqHeTemperatureCelsius}); |
| 96 |
if ($checked == 0) { |
| 97 |
my $warn_th = ''; |
| 98 |
my $crit_th = $result->{cpqHeTemperatureThreshold} != -1 ? $result->{cpqHeTemperatureThreshold} : ''; |
| 99 |
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); |
| 100 |
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); |
| 101 |
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); |
| 102 |
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); |
| 103 |
} |
| 104 |
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { |
| 105 |
$self->{output}->output_add(severity => $exit2, |
| 106 |
short_msg => sprintf("Temperature '%s' %s is %s degree centigrade", $instance, $result->{cpqHeTemperatureLocale}, $result->{cpqHeTemperatureCelsius})); |
| 107 |
} |
| 108 |
$self->{output}->perfdata_add( |
| 109 |
unit => 'C', |
| 110 |
nlabel => 'hardware.temperature.celsius', |
| 111 |
instances => [$instance, $result->{cpqHeTemperatureLocale}], |
| 112 |
value => $result->{cpqHeTemperatureCelsius}, |
| 113 |
warning => $warn, |
| 114 |
critical => $crit |
| 115 |
); |
| 116 |
} |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
1; |