+ Fix division by zero

This commit is contained in:
garnier-quentin 2016-09-13 15:07:42 +02:00
parent 132d0c875e
commit e8cdfef72f
1 changed files with 5 additions and 1 deletions

View File

@ -81,7 +81,11 @@ sub custom_utils_calc {
my $diff_busy = $options{new_datas}->{$self->{instance} . '_busy_ticks'} - $options{old_datas}->{$self->{instance} . '_busy_ticks'};
my $diff_idle = $options{new_datas}->{$self->{instance} . '_idle_ticks'} - $options{old_datas}->{$self->{instance} . '_idle_ticks'};
if (($diff_busy + $diff_idle) == 0) {
$self->{error_msg} = "wait new values";
return -3;
}
$self->{result_values}->{utils} = $diff_busy * 100 / ($diff_busy + $diff_idle);
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;