diff --git a/.githooks/pre-commit.d/20_plugins.sh b/.githooks/pre-commit.d/20_plugins.sh index 2d092f9eef..8890524c5a 100644 --- a/.githooks/pre-commit.d/20_plugins.sh +++ b/.githooks/pre-commit.d/20_plugins.sh @@ -43,7 +43,7 @@ function check_constants() { grep -nH -- "-\(1\|2\|10\)[[:space:]]*=>[[:space:]]*1" "$file" > "$tmpfile" grep -nH "\[[:space:]]*[0-9]" "$file" >> "$tmpfile" if [ -s "$tmpfile" ] ; then - error "It seems that some counters are not using constants defined in centreon/plugins/constants.pm." + error "It seems that some counters are not using constants defined in centreon/plugins/constants.pm. You may also need to add `use centreon::plugins::constants qw(:counters);` in your file." cat $tmpfile fi } diff --git a/src/os/f5os/snmp/mode/hardware.pm b/src/os/f5os/snmp/mode/hardware.pm index b05c3ba21f..f2238f4abc 100644 --- a/src/os/f5os/snmp/mode/hardware.pm +++ b/src/os/f5os/snmp/mode/hardware.pm @@ -1,5 +1,5 @@ # -# Copyright 2024 Centreon (http://www.centreon.com/) +# Copyright Copyright 2026-Present Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -20,6 +20,7 @@ package os::f5os::snmp::mode::hardware; +use centreon::plugins::constants qw/:counters :values/; use base qw(centreon::plugins::templates::counter); use strict; @@ -34,8 +35,8 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'temperature', type => 0, skipped_code => { -10 => 1 } }, - { name => 'fans', type => 1, cb_prefix_output => 'prefix_fan_output', message_multiple => 'All fans are ok', skipped_code => { -10 => 1 } } + { name => 'temperature', type => COUNTER_TYPE_GLOBAL, skipped_code => { NO_VALUE() => 1 } }, + { name => 'fans', type => COUNTER_TYPE_INSTANCE, cb_prefix_output => 'prefix_fan_output', message_multiple => 'All fans are ok', skipped_code => { NO_VALUE() => 1 } } ]; $self->{maps_counters}->{temperature} = [ @@ -128,7 +129,14 @@ sub manage_selection { next unless /^$mapping->{tempCurrent}->{oid}\.(.*)$/; $result = $options{snmp}->map_instance(mapping => $mapping, results => $results->{$oid_temperatureStatsEntry}, instance => $1); - $result->{$_} *= 0.1 for keys %{$result}; + for my $key (keys %{$result}) { + if ($result->{$key} =~ /\./) { + $result->{$key} =~ s/[^0-9.]//g; # remove any quotation marks + $result->{$key} += 0; # STRING: "29.0" -> float 29.0 ( F5OS 1.5.4 case) + } else { + $result->{$key} *= 0.1; # INTEGER: 316 -> float 31.6 + } + } last }