(core) snmp_standard::mode::interfaces - fix percentage display outpu… (#3506)

This commit is contained in:
qgarnier 2022-02-23 16:11:45 +01:00 committed by GitHub
parent 24c094c369
commit 7690af9fcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}