Skip to content

Commit

Permalink
[fix] Workaround for devices which show zero CPUs
Browse files Browse the repository at this point in the history
In some rare cases it may happen that the hardware
mistakenly reports zero CPUs, in these cases we can
assume there's at least 1 CPU.

If the hardware has more than 1 CPU the load average
will still be wrong.
  • Loading branch information
nemesifier committed Jul 1, 2022
1 parent c5e50f5 commit 42957e2
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function resources.get_cpus()
local processors = processors_file:read('*a')
processors_file:close()
local cpus = tonumber(processors)
-- assume the hardware has at least 1 proc
if cpus == 0 then
return 1
end
return cpus
end

Expand Down

0 comments on commit 42957e2

Please sign in to comment.