11.09.2019, 06:33
Use this script to log CPU load to an object. Resident script sleep time controls how often load is calculated.
Code:
data = io.readfile('/proc/uptime'):split(' ')
total, idle = tonumber(data[ 1 ]), tonumber(data[ 2 ])
if prevtotal then
deltatotal = total - prevtotal
deltaidle = idle - previdle
load = math.floor((1 - (deltaidle / deltatotal)) * 100 + 0.5)
grp.update('32/0/0', load)
end
prevtotal, previdle = total, idle