gluon-announce: add number of CPUs

This commit is contained in:
Matthias Schiffer 2015-04-25 23:25:26 +02:00
parent 0d4dd90e2b
commit 6ee65907a4
1 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,14 @@
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