mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-06-21 05:45:43 +02:00
24 lines
No EOL
1 KiB
Text
24 lines
No EOL
1 KiB
Text
:local cpuarray
|
|
:set cpuarray ([/system resource get value-name=cpu-load])
|
|
:local rebootIfHigh true
|
|
:local cpusample 40
|
|
:for i from=1 to=[$cpusample -1] do={
|
|
delay 500ms;
|
|
set cpuarray ([/system resource get value-name=cpu-load],$cpuarray)
|
|
}
|
|
:local totalcpuarray 0
|
|
:foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)}
|
|
local avgcpu ($totalcpuarray / [:len $cpuarray])
|
|
if ($avgcpu > 68) do={
|
|
:global telegram
|
|
:local maxcpu ($cpuarray->0)
|
|
:local mincpu ($cpuarray->0)
|
|
:foreach i in=$cpuarray do={
|
|
if ($i > $maxcpu) do={ set maxcpu $i}
|
|
if ($i < $mincpu) do={ set mincpu $i}
|
|
}
|
|
:local sendToTelegram ("Mikrotik ".[/system resource get value-name=board-name]."(".[/sy id get value-name=name].") :%0A\E2\9A\A0 \E2\9A\A0 <b>CPU Tinggi Gan!!</b>\
|
|
%0AMax: $maxcpu%0AMin: $mincpu%0ARata-Rata: $avgcpu%25%0AJumlah Data: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh")
|
|
$telegram type=message text=$sendToTelegram mode=html
|
|
if ($rebootIfHigh = true) do={/system reboot}
|
|
} |