From d71c51b57cd2cb62ef65bc54113d0b582b387b0a Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Wed, 12 Mar 2014 17:39:41 +0100 Subject: [PATCH] Fix #5354 --- os/linux/local/mode/traffic.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/os/linux/local/mode/traffic.pm b/os/linux/local/mode/traffic.pm index 3f632059a..ff79e3fe8 100644 --- a/os/linux/local/mode/traffic.pm +++ b/os/linux/local/mode/traffic.pm @@ -198,13 +198,15 @@ sub run { my $out_absolute_per_sec = ($new_datas->{'out_' . $name} - $old_out) / $time_delta; my ($exit, $interface_speed, $in_prct, $out_prct); - if ($self->{option_results}->{units} eq '%') { + if (defined($self->{option_results}->{speed})) { $interface_speed = $self->{option_results}->{speed} * 1000000; $in_prct = $in_absolute_per_sec * 100 / ($self->{option_results}->{speed} * 1000000); $out_prct = $out_absolute_per_sec * 100 / ($self->{option_results}->{speed} * 1000000); - my $exit1 = $self->{perfdata}->threshold_check(value => $in_prct, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $out_prct, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]); - $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); + if ($self->{option_results}->{units} eq '%') { + my $exit1 = $self->{perfdata}->threshold_check(value => $in_prct, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]); + my $exit2 = $self->{perfdata}->threshold_check(value => $out_prct, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]); + $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); + } $in_prct = sprintf("%.2f", $in_prct); $out_prct = sprintf("%.2f", $out_prct); } else {