From 2b66ed321efad71e2267028171358a641a6a852d Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Fri, 30 Mar 2018 04:10:14 +0200 Subject: [PATCH] plugin xen_cpu_v2: prevent "divide by zero" Closes: #475 --- plugins/xen/xen_cpu_v2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/xen/xen_cpu_v2 b/plugins/xen/xen_cpu_v2 index 75c9a951..aa58184c 100755 --- a/plugins/xen/xen_cpu_v2 +++ b/plugins/xen/xen_cpu_v2 @@ -171,8 +171,12 @@ while (($key, $value) = each %dom) # Calc a percentage based on the _total_ available CPU time $tmp = 0; - $tmp = ( $dom{$key}->{'diff'} / $tcpuavail ) * 100; - $dom{$key}->{'pc_tcpu'} = sprintf("%.2f", $tmp); + if ($tcpuavail != 0) { + $tmp = ( $dom{$key}->{'diff'} / $tcpuavail ) * 100; + $dom{$key}->{'pc_tcpu'} = sprintf("%.2f", $tmp); + } else { + $dom{$key}->{'pc_tcpu'} = "U"; + } if ( $debug ) {