check-health: monitor CPU load

---- ✂️ ----
🧮📈️ Health warning: CPU load

The average CPU load on MikroTik is at 76%!
---- ✂️ ----
🧮📉️ Health recovery: CPU load

The average CPU load on MikroTik decreased to 64%.
---- ✂️ ----
This commit is contained in:
Christian Hesse 2023-01-20 14:24:20 +01:00
parent 2694f8d2b1
commit 75bd14267e
10 changed files with 30 additions and 7 deletions

View file

@ -10,6 +10,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global CheckHealthCPULoad;
:global CheckHealthCPULoadNotified;
:global CheckHealthLast;
:global CheckHealthTemperature;
:global CheckHealthTemperatureDeviation;
@ -43,6 +45,20 @@
$ScriptLock $0;
:set CheckHealthCPULoad (($CheckHealthCPULoad * 4 + [ /system/resource/get cpu-load ] * 10) / 5);
:if ($CheckHealthCPULoad > 750 && $CheckHealthCPULoadNotified != true) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "abacus,chart-increasing" ] . "Health warning: CPU load"); \
message=("The average CPU load on " . $Identity . " is at " . ($CheckHealthCPULoad / 10) . "%!") });
:set CheckHealthCPULoadNotified true;
}
:if ($CheckHealthCPULoad < 650 && $CheckHealthCPULoadNotified = true) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "abacus,chart-decreasing" ] . "Health recovery: CPU load"); \
message=("The average CPU load on " . $Identity . " decreased to " . ($CheckHealthCPULoad / 10) . "%.") });
:set CheckHealthCPULoadNotified false;
}
:foreach Voltage in=[ /system/health/find where type="V" ] do={
:local Name [ /system/health/get $Voltage name ];
:local Value [ /system/health/get $Voltage value ];