This repository has been archived on 2024-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
gluon-firmware/package/gluon-announce/files/lib/gluon/announce/nodeinfo.d/hardware/nproc

15 lines
264 B
Plaintext

local n = 0
local cpus = util.trim(fs.readfile('/sys/devices/system/cpu/online'))
for _, entry in ipairs(cpus:split(',')) do
local x, y = entry:match('(%d+)-(%d+)')
if x then
n = n + tonumber(y) - tonumber(x) + 1
else
n = n + 1
end
end
return n