Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/pre-commit.d/20_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function check_constants() {
grep -nH -- "-\(1\|2\|10\)[[:space:]]*=>[[:space:]]*1" "$file" > "$tmpfile"
grep -nH "\<type[[:space:]]*=>[[: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
}
Expand Down
16 changes: 12 additions & 4 deletions src/os/f5os/snmp/mode/hardware.pm
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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} = [
Expand Down Expand Up @@ -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
}
Expand Down
Loading