+ fix illegal division for linux cpu local mode (Fix #88)

This commit is contained in:
garnier-quentin 2015-06-29 17:07:47 +02:00
parent 5314b44d53
commit 18b16c4ab8
1 changed files with 6 additions and 0 deletions

View File

@ -131,6 +131,12 @@ sub run {
}
my $total_elapsed = ($datas->{'cpu_idle_' . $cpu_number} + $datas->{'cpu_user_' . $cpu_number} + $datas->{'cpu_system_' . $cpu_number} + $datas->{'cpu_iowait_' . $cpu_number}) - ($old_cpu_user + $old_cpu_idle + $old_cpu_system + $old_cpu_iowait);
if ($total_elapsed == 0) {
$self->{output}->output_add(severity => 'OK',
short_msg => "No new values for cpu counters");
$self->{output}->display();
$self->{output}->exit();
}
my $idle_elapsed = $datas->{'cpu_idle_' . $cpu_number} - $old_cpu_idle;
my $cpu_ratio_usetime = 100 * $idle_elapsed / $total_elapsed;
$cpu_ratio_usetime = 100 - $cpu_ratio_usetime;