mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-06-21 05:45:43 +02:00
added check connection function and update cpu-monitoring
This commit is contained in:
parent
f03e93151b
commit
840defec9b
2 changed files with 14 additions and 8 deletions
|
@ -15,14 +15,10 @@ foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)}
|
||||||
:put $totalcpuarray
|
:put $totalcpuarray
|
||||||
local avgcpu ($totalcpuarray / [:len $cpuarray])
|
local avgcpu ($totalcpuarray / [:len $cpuarray])
|
||||||
if ($avgcpu > 65) do={
|
if ($avgcpu > 65) do={
|
||||||
tool flood-ping 8.8.8.8 count=10 do={
|
global CheckConnection
|
||||||
/if ($received > 8) do={
|
$CheckConnection
|
||||||
set $isInternetConnected [tobool true]
|
global ConnectionAvailable
|
||||||
} else={
|
if ($ConnectionAvailable=true) do={
|
||||||
set $isInternetConnected [tobool false]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isInternetConnected=true) do={
|
|
||||||
global CHATID
|
global CHATID
|
||||||
global BOTID
|
global BOTID
|
||||||
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 Load Report</b>%0AAverage: $avgcpu%25%0ACPU Samples: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh")
|
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 Load Report</b>%0AAverage: $avgcpu%25%0ACPU Samples: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh")
|
||||||
|
|
10
first-setup
10
first-setup
|
@ -38,3 +38,13 @@ global ConvertUpperCase do={
|
||||||
}
|
}
|
||||||
:return $result
|
:return $result
|
||||||
}
|
}
|
||||||
|
global CheckConnection do={
|
||||||
|
global ConnectionAvailable
|
||||||
|
tool flood-ping 8.8.8.8 count=10 do={
|
||||||
|
/if ($received > 8) do={
|
||||||
|
set $ConnectionAvailable [tobool true]
|
||||||
|
} else={
|
||||||
|
set $ConnectionAvailable [tobool false]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue