| 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::temperature; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use centreon::plugins::misc; |
| 26 |
|
| 27 |
my %map_temp_status = (); |
| 28 |
my ($oid_tempSensorDescription, $oid_tempSensorCurrentValue, $oid_tempSensorStatus); |
| 29 |
my $oid_temperatureSensorEntry = '.1.3.6.1.4.1.19746.1.1.2.1.1.1'; |
| 30 |
|
| 31 |
sub load { |
| 32 |
my ($self) = @_; |
| 33 |
|
| 34 |
push @{$self->{request}}, { oid => $oid_temperatureSensorEntry }; |
| 35 |
} |
| 36 |
|
| 37 |
sub check { |
| 38 |
my ($self) = @_; |
| 39 |
|
| 40 |
$self->{output}->output_add(long_msg => "Checking temperatures"); |
| 41 |
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; |
| 42 |
return if ($self->check_filter(section => 'temperature')); |
| 43 |
|
| 44 |
if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { |
| 45 |
$oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; |
| 46 |
$oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; |
| 47 |
$oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.6'; |
| 48 |
%map_temp_status = ( |
| 49 |
0 => 'failed', 1 => 'ok', 2 => 'notfound', 3 => 'overheatWarning', |
| 50 |
4 => 'overheatCritical' |
| 51 |
); |
| 52 |
} else { |
| 53 |
$oid_tempSensorDescription = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.3'; |
| 54 |
$oid_tempSensorCurrentValue = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.4'; |
| 55 |
$oid_tempSensorStatus = '.1.3.6.1.4.1.19746.1.1.2.1.1.1.5'; |
| 56 |
%map_temp_status = (0 => 'absent', 1 => 'ok', 2 => 'notfound'); |
| 57 |
} |
| 58 |
|
| 59 |
foreach my $oid (keys %{$self->{results}->{$oid_temperatureSensorEntry}}) { |
| 60 |
next if ($oid !~ /^$oid_tempSensorStatus\.(.*)$/); |
| 61 |
my $instance = $1; |
| 62 |
my $temp_descr = defined($self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorDescription . '.' . $instance}) ? |
| 63 |
centreon::plugins::misc::trim($self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorDescription . '.' . $instance}) : 'unknown'; |
| 64 |
my $temp_status = defined($map_temp_status{$self->{results}->{$oid_temperatureSensorEntry}->{$oid}}) ? |
| 65 |
$map_temp_status{$self->{results}->{$oid_temperatureSensorEntry}->{$oid}} : 'unknown'; |
| 66 |
my $temp_value = $self->{results}->{$oid_temperatureSensorEntry}->{$oid_tempSensorCurrentValue . '.' . $instance}; |
| 67 |
|
| 68 |
next if ($self->check_filter(section => 'temperature', instance => $instance)); |
| 69 |
next if ($temp_status =~ /absent|notfound/i && |
| 70 |
$self->absent_problem(section => 'temperature', instance => $instance)); |
| 71 |
|
| 72 |
$self->{components}->{temperature}->{total}++; |
| 73 |
$self->{output}->output_add( |
| 74 |
long_msg => sprintf( |
| 75 |
"temperature '%s' status is '%s' [instance: %s]", |
| 76 |
$temp_descr, $temp_status, $instance |
| 77 |
) |
| 78 |
); |
| 79 |
my $exit = $self->get_severity(section => 'temperature', value => $temp_status); |
| 80 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 81 |
$self->{output}->output_add( |
| 82 |
severity => $exit, |
| 83 |
short_msg => sprintf("Temperature '%s' status is '%s'", $temp_descr, $temp_status) |
| 84 |
); |
| 85 |
} |
| 86 |
|
| 87 |
if (defined($temp_value) && $temp_value =~ /[0-9]/) { |
| 88 |
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temp_value); |
| 89 |
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s degree centigrade", $temp_descr, $temp_value)); |
| 90 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 91 |
$self->{output}->output_add( |
| 92 |
severity => $exit, |
| 93 |
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $temp_descr, $temp_value) |
| 94 |
); |
| 95 |
} |
| 96 |
|
| 97 |
$self->{output}->perfdata_add( |
| 98 |
nlabel => 'hardware.temperature.celsius', |
| 99 |
unit => 'C', |
| 100 |
instances => $instance, |
| 101 |
value => $temp_value, |
| 102 |
warning => $warn, |
| 103 |
critical => $crit |
| 104 |
); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
1; |