| 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 network::hp::procurve::snmp::mode::components::sensor; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_status = ( |
| 27 |
1 => 'unknown', |
| 28 |
2 => 'bad', |
| 29 |
3 => 'warning', |
| 30 |
4 => 'good', |
| 31 |
5 => 'not present', |
| 32 |
); |
| 33 |
my %object_map = ( |
| 34 |
'.1.3.6.1.4.1.11.2.3.7.8.3.1' => 'power supply', #icfPowerSupplySensor |
| 35 |
'.1.3.6.1.4.1.11.2.3.7.8.3.2' => 'fan', #icfFanSensor |
| 36 |
'.1.3.6.1.4.1.11.2.3.7.8.3.3' => 'temperature', #icfTemperatureSensor |
| 37 |
'.1.3.6.1.4.1.11.2.3.7.8.3.4' => 'future slot', #icfFutureSlotSensor |
| 38 |
); |
| 39 |
|
| 40 |
my $mapping = { |
| 41 |
hpicfSensorObjectId => { oid => '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.2', map => \%object_map }, |
| 42 |
hpicfSensorStatus => { oid => '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.4', map => \%map_status }, |
| 43 |
hpicfSensorDescr => { oid => '.1.3.6.1.4.1.11.2.14.11.1.2.6.1.7' }, |
| 44 |
}; |
| 45 |
my $oid_hpicfSensorEntry = '.1.3.6.1.4.1.11.2.14.11.1.2.6.1'; |
| 46 |
|
| 47 |
sub load { |
| 48 |
my ($self) = @_; |
| 49 |
|
| 50 |
push @{$self->{request}}, { oid => $oid_hpicfSensorEntry }; |
| 51 |
} |
| 52 |
|
| 53 |
sub check { |
| 54 |
my ($self) = @_; |
| 55 |
|
| 56 |
$self->{output}->output_add(long_msg => "Checking sensors"); |
| 57 |
$self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0}; |
| 58 |
return if ($self->check_filter(section => 'sensor')); |
| 59 |
|
| 60 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hpicfSensorEntry}})) { |
| 61 |
next if ($oid !~ /^$mapping->{hpicfSensorStatus}->{oid}\.(.*)$/); |
| 62 |
my $instance_mapping = $1; |
| 63 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hpicfSensorEntry}, instance => $instance_mapping); |
| 64 |
my $instance = $result->{hpicfSensorObjectId} . '.' . $instance_mapping; |
| 65 |
|
| 66 |
next if ($self->check_filter(section => 'sensor', instance => $instance)); |
| 67 |
next if ($result->{hpicfSensorStatus} =~ /not present/i && |
| 68 |
$self->absent_problem(section => 'sensor', instance => $instance)); |
| 69 |
$self->{components}->{sensor}->{total}++; |
| 70 |
|
| 71 |
$self->{output}->output_add(long_msg => sprintf("%s sensor '%s' state is %s [instance: %s].", |
| 72 |
$result->{hpicfSensorObjectId}, $instance, $result->{hpicfSensorStatus}, $instance |
| 73 |
)); |
| 74 |
my $exit = $self->get_severity(section => 'sensor', value => $result->{hpicfSensorStatus}); |
| 75 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 76 |
$self->{output}->output_add(severity => $exit, |
| 77 |
short_msg => sprintf("%s sensor '%s' state is %s", |
| 78 |
$result->{hpicfSensorObjectId}, $instance, $result->{hpicfSensorStatus})); |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
1; |