Update cpu.lua (#506)

I noticed once that the CPU usage was being reported as being '-1%', I dug around the code for a while and think that the change at line 52 should make sure no negative values are obtained.

Co-authored-by: Pratik Devkota <pratikdevkota82@gmail.com>
This commit is contained in:
Pratik Devkota 2021-07-01 19:07:07 +00:00 committed by GitHub
parent 2e5660faf8
commit 6bf79c30ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -49,7 +49,7 @@ local function factory(args)
-- Read current data and calculate relative values. -- Read current data and calculate relative values.
local dactive = active - core.last_active local dactive = active - core.last_active
local dtotal = total - core.last_total local dtotal = total - core.last_total
local usage = math.ceil((dactive / dtotal) * 100) local usage = math.ceil(math.abs((dactive / dtotal) * 100))
core.last_active = active core.last_active = active
core.last_total = total core.last_total = total