diff --git a/centreon/common/cisco/standard/snmp/mode/components/sensor.pm b/centreon/common/cisco/standard/snmp/mode/components/sensor.pm index 28c7a2dbc..7a4e7653e 100644 --- a/centreon/common/cisco/standard/snmp/mode/components/sensor.pm +++ b/centreon/common/cisco/standard/snmp/mode/components/sensor.pm @@ -22,6 +22,7 @@ package centreon::common::cisco::standard::snmp::mode::components::sensor; use strict; use warnings; +use centreon::plugins::misc; my %map_sensor_status = ( 1 => 'ok', @@ -140,8 +141,9 @@ sub get_default_warning_threshold { } my $th = ''; - $th = $low_th . ':' if (defined($low_th)); - $th .= $high_th if (defined($high_th)); + $th = centreon::plugins::misc::expand_exponential(value => $low_th) . ':' if (defined($low_th)); + $th .= centreon::plugins::misc::expand_exponential(value => $high_th) if (defined($high_th)); + return $th; } @@ -168,8 +170,9 @@ sub get_default_critical_threshold { } my $th = ''; - $th = $low_th . ':' if (defined($low_th)); - $th .= $high_th if (defined($high_th)); + $th = centreon::plugins::misc::expand_exponential(value => $low_th) . ':' if (defined($low_th)); + $th .= centreon::plugins::misc::expand_exponential(value => $high_th) if (defined($high_th)); + return $th; } @@ -231,4 +234,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/centreon/plugins/misc.pm b/centreon/plugins/misc.pm index ea184d66a..24bcafe11 100644 --- a/centreon/plugins/misc.pm +++ b/centreon/plugins/misc.pm @@ -438,6 +438,15 @@ sub convert_bytes { return $value; } +sub expand_exponential { + my (%options) = @_; + + return $options{value} unless ($options{value} =~ /^(.*)e([-+]?)(.*)$/); + my ($num, $sign, $exp) = ($1, $2, $3); + my $sig = $sign eq '-' ? "." . ($exp - 1 + length $num) : ''; + return sprintf("%${sig}f", $options{value}); +} + sub parse_threshold { my (%options) = @_;