diff --git a/cpu-monitoring b/cpu-monitoring index c67a83e..ee82d4b 100644 --- a/cpu-monitoring +++ b/cpu-monitoring @@ -15,14 +15,10 @@ foreach value in=$cpuarray do={ set totalcpuarray ($totalcpuarray + $value)} :put $totalcpuarray local avgcpu ($totalcpuarray / [:len $cpuarray]) if ($avgcpu > 65) do={ - tool flood-ping 8.8.8.8 count=10 do={ - /if ($received > 8) do={ - set $isInternetConnected [tobool true] - } else={ - set $isInternetConnected [tobool false] - } - } - if ($isInternetConnected=true) do={ + global CheckConnection + $CheckConnection + global ConnectionAvailable + if ($ConnectionAvailable=true) do={ global CHATID 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 CPU Load Report%0AAverage: $avgcpu%25%0ACPU Samples: $cpusample%0AReboot if CPU sample show highload: $rebootIfHigh") diff --git a/first-setup b/first-setup index 6bf3276..74c23fa 100644 --- a/first-setup +++ b/first-setup @@ -38,3 +38,13 @@ global ConvertUpperCase do={ } :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] + } + } +} \ No newline at end of file