From 18b16c4ab80245ede5b7b2a9135491116e42ed25 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 29 Jun 2015 17:07:47 +0200 Subject: [PATCH] + fix illegal division for linux cpu local mode (Fix #88) --- os/linux/local/mode/cpu.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/os/linux/local/mode/cpu.pm b/os/linux/local/mode/cpu.pm index c49ad1b60..ac0051655 100644 --- a/os/linux/local/mode/cpu.pm +++ b/os/linux/local/mode/cpu.pm @@ -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;