mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-06-21 13:49:01 +02:00
update cpu-monitoring to use local variable
This commit is contained in:
parent
b1fe41c7b9
commit
a0af6921c4
1 changed files with 5 additions and 7 deletions
|
@ -1,16 +1,14 @@
|
||||||
global cpuarray ([/system resource get value-name=cpu-load])
|
local cpuarray
|
||||||
local isInternetConnected
|
local isInternetConnected
|
||||||
local rebootIfHigh false
|
local rebootIfHigh false
|
||||||
local setup do={
|
set cpuarray ([/system resource get value-name=cpu-load])
|
||||||
delay 950ms;
|
|
||||||
global cpuarray
|
|
||||||
set cpuarray ([/system resource get value-name=cpu-load],$cpuarray)
|
|
||||||
}
|
|
||||||
#Change the value below to change the number of CPU load sample to average
|
#Change the value below to change the number of CPU load sample to average
|
||||||
local cpusample 20
|
local cpusample 20
|
||||||
for i from=1 to=[$cpusample -1] do={
|
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
|
local totalcpuarray 0
|
||||||
#calculating the average
|
#calculating the average
|
||||||
foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)}
|
foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue