From 7690af9fcc478072a036b6d04af911ff55a1528a Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 23 Feb 2022 16:11:45 +0100 Subject: [PATCH] =?UTF-8?q?(core)=20snmp=5Fstandard::mode::interfaces=20-?= =?UTF-8?q?=20fix=20percentage=20display=20outpu=E2=80=A6=20(#3506)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- os/windows/wsman/mode/interfaces.pm | 3 +++ snmp_standard/mode/interfaces.pm | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/os/windows/wsman/mode/interfaces.pm b/os/windows/wsman/mode/interfaces.pm index d16ead2fc..bee2b10f4 100644 --- a/os/windows/wsman/mode/interfaces.pm +++ b/os/windows/wsman/mode/interfaces.pm @@ -187,9 +187,12 @@ sub custom_errors_calc { } elsif ($self->{instance_mode}->{option_results}->{units_errors} eq 'percent') { $self->{result_values}->{prct} = $errors * 100 / $total if ($total > 0); $self->{result_values}->{used} = $errors; + $self->{result_values}->{total} = $total; } elsif ($self->{instance_mode}->{option_results}->{units_errors} eq 'delta') { + $self->{result_values}->{prct} = $errors_diff * 100 / $total_diff if ($total_diff > 0); $self->{result_values}->{used} = $errors_diff; } else { + $self->{result_values}->{prct} = $errors * 100 / $total if ($total > 0); $self->{result_values}->{used} = $errors; $self->{result_values}->{total} = $total; } diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index f0415bc07..cb6f3688c 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -159,9 +159,12 @@ sub custom_cast_calc { } elsif ($self->{instance_mode}->{option_results}->{units_cast} eq 'percent') { $self->{result_values}->{prct} = $cast * 100 / $total if ($total > 0); $self->{result_values}->{used} = $cast; + $self->{result_values}->{total} = $total; } elsif ($self->{instance_mode}->{option_results}->{units_cast} eq 'delta') { + $self->{result_values}->{prct} = $cast_diff * 100 / $total_diff if ($total_diff > 0); $self->{result_values}->{used} = $cast_diff; } else { + $self->{result_values}->{prct} = $cast_diff * 100 / $total_diff if ($total_diff > 0); $self->{result_values}->{used} = $cast; $self->{result_values}->{total} = $total; } @@ -355,9 +358,12 @@ sub custom_errors_calc { } elsif ($self->{instance_mode}->{option_results}->{units_errors} eq 'percent') { $self->{result_values}->{prct} = $errors * 100 / $total if ($total > 0); $self->{result_values}->{used} = $errors; + $self->{result_values}->{total} = $total; } elsif ($self->{instance_mode}->{option_results}->{units_errors} eq 'delta') { + $self->{result_values}->{prct} = $errors_diff * 100 / $total_diff if ($total_diff > 0); $self->{result_values}->{used} = $errors_diff; } else { + $self->{result_values}->{prct} = $errors * 100 / $total if ($total > 0); $self->{result_values}->{used} = $errors; $self->{result_values}->{total} = $total; }