15 lines
264 B
Plaintext
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
|