update cpu-monitoring to use local variable

This commit is contained in:
furaihan 2020-09-02 23:32:00 +07:00
parent b1fe41c7b9
commit a0af6921c4

View file

@ -1,16 +1,14 @@
global cpuarray ([/system resource get value-name=cpu-load])
local cpuarray
local isInternetConnected
local rebootIfHigh false
local setup do={
delay 950ms;
global cpuarray
set cpuarray ([/system resource get value-name=cpu-load],$cpuarray)
}
set cpuarray ([/system resource get value-name=cpu-load])
#Change the value below to change the number of CPU load sample to average
local cpusample 20
for i from=1 to=[$cpusample -1] do={
$setup
delay 950ms;
set cpuarray ([/system resource get value-name=cpu-load],$cpuarray)
}
put $cpuarray
local totalcpuarray 0
#calculating the average
foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)}