| 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::dell::idrac::snmp::mode::components::temperature; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_probe_status %map_state); |
| 26 |
|
| 27 |
my %map_temp_type = ( |
| 28 |
1 => 'temperatureProbeTypeIsOther', |
| 29 |
2 => 'temperatureProbeTypeIsUnknown', |
| 30 |
3 => 'temperatureProbeTypeIsAmbientESM', |
| 31 |
16 => 'temperatureProbeTypeIsDiscrete' |
| 32 |
); |
| 33 |
|
| 34 |
my $mapping = { |
| 35 |
temperatureProbeStateSettings => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.4', map => \%map_state }, |
| 36 |
temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.5', map => \%map_probe_status }, |
| 37 |
temperatureProbeReading => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.6' }, |
| 38 |
temperatureProbeType => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.7', map => \%map_temp_type }, |
| 39 |
temperatureProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.8' }, |
| 40 |
temperatureProbeUpperCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.10' }, |
| 41 |
temperatureProbeUpperNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.11' }, |
| 42 |
temperatureProbeLowerNonCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.12' }, |
| 43 |
temperatureProbeLowerCriticalThreshold => { oid => '.1.3.6.1.4.1.674.10892.5.4.700.20.1.13' } |
| 44 |
}; |
| 45 |
my $oid_temperatureProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.20.1'; |
| 46 |
|
| 47 |
sub load { |
| 48 |
my ($self) = @_; |
| 49 |
|
| 50 |
push @{$self->{request}}, { |
| 51 |
oid => $oid_temperatureProbeTableEntry, |
| 52 |
start => $mapping->{temperatureProbeStateSettings}->{oid}, |
| 53 |
end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} |
| 54 |
}; |
| 55 |
} |
| 56 |
|
| 57 |
sub check { |
| 58 |
my ($self) = @_; |
| 59 |
|
| 60 |
$self->{output}->output_add(long_msg => "Checking temperatures"); |
| 61 |
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; |
| 62 |
return if ($self->check_filter(section => 'temperature')); |
| 63 |
|
| 64 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTableEntry}})) { |
| 65 |
next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(\d+)\.(\d+)$/); |
| 66 |
my $instance = $1 . '.' . $2; |
| 67 |
my $chassis_name = $self->get_chassis_name(id => $1); |
| 68 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTableEntry}, instance => $instance); |
| 69 |
|
| 70 |
next if ($self->check_filter(section => 'temperature', instance => $instance, name => $result->{temperatureProbeLocationName})); |
| 71 |
$self->{components}->{temperature}->{total}++; |
| 72 |
|
| 73 |
$result->{temperatureProbeReading} = (defined($result->{temperatureProbeReading})) ? $result->{temperatureProbeReading} / 10 : 'unknown'; |
| 74 |
$self->{output}->output_add( |
| 75 |
long_msg => sprintf( |
| 76 |
"temperature '%s' status is '%s' [instance: %s] [state: %s] [value: %s]", |
| 77 |
$result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus}, $instance, |
| 78 |
$result->{temperatureProbeStateSettings}, $result->{temperatureProbeReading} |
| 79 |
) |
| 80 |
); |
| 81 |
|
| 82 |
my $exit = $self->get_severity(label => 'default.state', section => 'temperature.state', value => $result->{temperatureProbeStateSettings}); |
| 83 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 84 |
$self->{output}->output_add( |
| 85 |
severity => $exit, |
| 86 |
short_msg => sprintf( |
| 87 |
"Temperature '%s' state is '%s'", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStateSettings} |
| 88 |
) |
| 89 |
); |
| 90 |
next; |
| 91 |
} |
| 92 |
|
| 93 |
$exit = $self->get_severity(label => 'probe.status', section => 'temperature.status', value => $result->{temperatureProbeStatus}); |
| 94 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 95 |
$self->{output}->output_add( |
| 96 |
severity => $exit, |
| 97 |
short_msg => sprintf( |
| 98 |
"Temperature '%s' status is '%s'", $result->{temperatureProbeLocationName}, $result->{temperatureProbeStatus} |
| 99 |
) |
| 100 |
); |
| 101 |
} |
| 102 |
|
| 103 |
if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) { |
| 104 |
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric( |
| 105 |
section => 'temperature', |
| 106 |
instance => $instance, |
| 107 |
name => $result->{temperatureProbeLocationName}, |
| 108 |
value => $result->{temperatureProbeReading} |
| 109 |
); |
| 110 |
if ($checked == 0) { |
| 111 |
$result->{temperatureProbeLowerNonCriticalThreshold} = (defined($result->{temperatureProbeLowerNonCriticalThreshold}) && $result->{temperatureProbeLowerNonCriticalThreshold} =~ /[0-9]/) ? |
| 112 |
$result->{temperatureProbeLowerNonCriticalThreshold} / 10 : ''; |
| 113 |
$result->{temperatureProbeLowerCriticalThreshold} = (defined($result->{temperatureProbeLowerCriticalThreshold}) && $result->{temperatureProbeLowerCriticalThreshold} =~ /[0-9]/) ? |
| 114 |
$result->{temperatureProbeLowerCriticalThreshold} / 10 : ''; |
| 115 |
$result->{temperatureProbeUpperNonCriticalThreshold} = (defined($result->{temperatureProbeUpperNonCriticalThreshold}) && $result->{temperatureProbeUpperNonCriticalThreshold} =~ /[0-9]/) ? |
| 116 |
$result->{temperatureProbeUpperNonCriticalThreshold} / 10 : ''; |
| 117 |
$result->{temperatureProbeUpperCriticalThreshold} = (defined($result->{temperatureProbeUpperCriticalThreshold}) && $result->{temperatureProbeUpperCriticalThreshold} =~ /[0-9]/) ? |
| 118 |
$result->{temperatureProbeUpperCriticalThreshold} / 10 : ''; |
| 119 |
my $warn_th = $result->{temperatureProbeLowerNonCriticalThreshold} . ':' . $result->{temperatureProbeUpperNonCriticalThreshold}; |
| 120 |
my $crit_th = $result->{temperatureProbeLowerCriticalThreshold} . ':' . $result->{temperatureProbeUpperCriticalThreshold}; |
| 121 |
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); |
| 122 |
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); |
| 123 |
|
| 124 |
$exit = $self->{perfdata}->threshold_check( |
| 125 |
value => $result->{temperatureProbeReading}, |
| 126 |
threshold => [ |
| 127 |
{ label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, |
| 128 |
{ label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } |
| 129 |
] |
| 130 |
); |
| 131 |
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); |
| 132 |
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); |
| 133 |
} |
| 134 |
|
| 135 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 136 |
$self->{output}->output_add( |
| 137 |
severity => $exit, |
| 138 |
short_msg => sprintf( |
| 139 |
"Temperature '%s' is %s degree centigrade", $result->{temperatureProbeLocationName}, $result->{temperatureProbeReading} |
| 140 |
) |
| 141 |
); |
| 142 |
} |
| 143 |
$self->{output}->perfdata_add( |
| 144 |
nlabel => 'hardware.probe.temperature.celsius', |
| 145 |
unit => 'C', |
| 146 |
instances => [$chassis_name, $result->{temperatureProbeLocationName}], |
| 147 |
value => $result->{temperatureProbeReading}, |
| 148 |
warning => $warn, |
| 149 |
critical => $crit |
| 150 |
); |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
1; |