| 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::ibm::nos::snmp::mode::components::temperature; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
sub load {} |
| 27 |
|
| 28 |
sub check { |
| 29 |
my ($self) = @_; |
| 30 |
|
| 31 |
$self->{output}->output_add(long_msg => 'checking temperatures'); |
| 32 |
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; |
| 33 |
return if ($self->check_filter(section => 'temperature')); |
| 34 |
|
| 35 |
my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.26543.2.5.1.3.1.22.0'; |
| 36 |
my $oid_hwTemperatureShut = '.1.3.6.1.4.1.26543.2.5.1.3.1.23.0'; |
| 37 |
my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut]); |
| 38 |
|
| 39 |
return if (!defined($results->{$oid_hwTemperatureWarn})); |
| 40 |
|
| 41 |
my $instance = 'system'; |
| 42 |
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warn at 66 C / Recover at 61 C)" |
| 43 |
# .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" |
| 44 |
$results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; |
| 45 |
my ($temperature, $warning_mib) = ($1, $2); |
| 46 |
$results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; |
| 47 |
$temperature = $1 if ($1 > $temperature); |
| 48 |
my $critical_mib = ($warning_mib + $2) / 2; |
| 49 |
|
| 50 |
if ($warning_mib == $critical_mib) { #seen on some chassis ! |
| 51 |
$warning_mib -= 10; |
| 52 |
$critical_mib -= 5; |
| 53 |
} |
| 54 |
|
| 55 |
$self->{components}->{temperature}->{total}++; |
| 56 |
|
| 57 |
$self->{output}->output_add(long_msg => |
| 58 |
sprintf( |
| 59 |
"temperature '%s' is %.1f C [instance: %s]", |
| 60 |
$instance, |
| 61 |
$temperature, |
| 62 |
$instance |
| 63 |
) |
| 64 |
); |
| 65 |
|
| 66 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature); |
| 67 |
if ($checked == 0) { |
| 68 |
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warning_mib); |
| 69 |
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $critical_mib); |
| 70 |
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); |
| 71 |
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); |
| 72 |
$exit = $self->{perfdata}->threshold_check( |
| 73 |
value => $temperature, |
| 74 |
threshold => [ |
| 75 |
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, |
| 76 |
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } |
| 77 |
] |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 82 |
$self->{output}->output_add( |
| 83 |
severity => $exit, |
| 84 |
short_msg => sprintf( |
| 85 |
"Temperature '%s' is %.1f C", |
| 86 |
$instance, |
| 87 |
$temperature |
| 88 |
) |
| 89 |
); |
| 90 |
} |
| 91 |
|
| 92 |
$self->{output}->perfdata_add( |
| 93 |
unit => 'C', |
| 94 |
nlabel => 'hardware.temperature.celsius', |
| 95 |
instances => 'system', |
| 96 |
value => $temperature, |
| 97 |
warning => $warn, |
| 98 |
critical => $crit |
| 99 |
); |
| 100 |
} |
| 101 |
|
| 102 |
1; |