From 1b91897ae09338281a6f763108fd7d15f27e2f03 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut Date: Fri, 27 Jun 2025 15:16:26 +0200 Subject: [PATCH] fix(hardware::server::huawei::hmm::snmp): fixed temperature issue and work on hardware template issue --- src/centreon/plugins/templates/hardware.pm | 22 ++++++++++++++----- .../hmm/snmp/mode/components/temperature.pm | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/centreon/plugins/templates/hardware.pm b/src/centreon/plugins/templates/hardware.pm index a53d43926..3862f90d6 100644 --- a/src/centreon/plugins/templates/hardware.pm +++ b/src/centreon/plugins/templates/hardware.pm @@ -137,12 +137,18 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - if (defined($self->{option_results}->{no_component})) { - if ($self->{option_results}->{no_component} ne '') { - $self->{no_components} = $self->{option_results}->{no_component}; - } else { - $self->{no_components} = 'critical'; - } + use Data::Dumper; + print Dumper("Hardware template check_options start here"); + + print Dumper("\$self->{option_results}->{no_component} is defined ? ".defined($self->{option_results}->{no_component})); + print Dumper("\$self->{option_results}->{no_component} ne '' ? ".($self->{option_results}->{no_component} ne '')); + + if (defined($self->{option_results}->{no_component}) && ($self->{option_results}->{no_component} ne '')) { + $self->{no_components} = $self->{option_results}->{no_component}; + } else { + print Dumper("\$self->{option_results}->{no_component} not defined so set as critical"); + $self->{no_components} = 'critical'; + print Dumper("\$self->{no_components} =".$self->{no_components}); } if ($self->{filter_exclude} == 1) { @@ -319,6 +325,10 @@ sub display { ); } + print Dumper("\$total_components = ".$total_components); + print Dumper("(option set by the user) : \$self->{option_results}->{no_component} = ".$self->{option_results}->{no_component}); + print Dumper("(option in self after check_option function) : \$self->{no_components} = ".$self->{no_components}); + if (defined($self->{option_results}->{no_component}) && $total_components == 0) { $self->{output}->output_add( severity => $self->{no_components}, diff --git a/src/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm b/src/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm index efecd015b..9a5ca5950 100644 --- a/src/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm +++ b/src/hardware/server/huawei/hmm/snmp/mode/components/temperature.pm @@ -48,7 +48,7 @@ sub check { return if ($self->check_filter(section => 'temperature')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_bladeTemperatureTable}})) { - next if ($oid !~ /^$mapping->{oid_bladeTemperatureTable}->{oid}\.(.*)$/); + next if ($oid !~ /^$mapping->{bladeTemperatureIndex}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_bladeTemperatureTable}, instance => $instance);