Logic Machine Forum
System Load Variable - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: System Load Variable (/showthread.php?tid=5654)



System Load Variable - pioneersteffen - 05.10.2024

Hi @all,

is there an option to call the actual system / processor load in a script? 

I haven’t found anything in the LUA reference manual.

Many thanks for your help!

Best regards 
Steffen


RE: System Load Variable - Fahd - 05.10.2024

Resident script with a 60-second sleep interval. 
Create two 2-byte objects and name them CPU and Memory.
Code:
load = io.readfile('/proc/loadavg'):split(' ')[ 1 ]
memtotal = data:match('MemTotal:%s+(%d+)')
memavail = data:match('MemAvailable:%s+(%d+)')
memusage = math.floor((memtotal - memavail) / memtotal * 1000) / 10
log(load, memusage)
grp.update('CPU', load)
grp.update('Memory', memusage)



RE: System Load Variable - admin - 07.10.2024

Check this: https://forum.logicmachine.net/showthread.php?tid=2233