fix exponential value for cisco thresholds
This commit is contained in:
parent
94525a03db
commit
42fa0a6b3a
|
@ -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;
|
||||
1;
|
||||
|
|
|
@ -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) = @_;
|
||||
|
||||
|
|
Loading…
Reference in New Issue