[cpu] fix division by zero

In rare cases diff_total seems to become 0.
This commit is contained in:
Joerg T. (Mic92) 2011-09-18 12:59:33 +02:00 committed by Adrian C. (anrxc)
parent 059442d039
commit eeb27a2916
1 changed files with 2 additions and 0 deletions

View File

@ -61,6 +61,8 @@ local function worker(format)
-- Calculate percentage
local diff_total = total_new - cpu_total[i]
local diff_active = active_new - cpu_active[i]
if diff_total == 0 then diff_total = 1E-6 end
cpu_usage[i] = math.floor((diff_active / diff_total) * 100)
-- Store totals