aboutsummaryrefslogtreecommitdiffstats
path: root/check-health
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-01-20 14:34:18 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-01-20 23:20:53 +0100
commit6780e1a24ccdefd3a328abe7ca8cef3d4ed57114 (patch)
treeea8aa37c8e586143f2e832ed42e8bf163d7348e1 /check-health
parent75bd14267e7a5507e0d58b9945dbb24e5d831af8 (diff)
check-health: monitor free RAM
---- ✂️ ---- 🗃️📉️ Health warning: free RAM The available free RAM on MikroTik is at 18% (47MiB)! ---- ✂️ ---- 🗃️📈️ Health recovery: free RAM The available free RAM on MikroTik increased to 65% (168MiB). ---- ✂️ ----
Diffstat (limited to 'check-health')
-rw-r--r--check-health22
1 files changed, 21 insertions, 1 deletions
diff --git a/check-health b/check-health
index 3957ad1..55ad8ab 100644
--- a/check-health
+++ b/check-health
@@ -12,6 +12,7 @@
:global CheckHealthCPULoad;
:global CheckHealthCPULoadNotified;
+:global CheckHealthFreeRAMNotified;
:global CheckHealthLast;
:global CheckHealthTemperature;
:global CheckHealthTemperatureDeviation;
@@ -45,7 +46,9 @@
$ScriptLock $0;
-:set CheckHealthCPULoad (($CheckHealthCPULoad * 4 + [ /system/resource/get cpu-load ] * 10) / 5);
+:local Resource [ /system/resource/get ];
+
+:set CheckHealthCPULoad (($CheckHealthCPULoad * 4 + ($Resource->"cpu-load") * 10) / 5);
:if ($CheckHealthCPULoad > 750 && $CheckHealthCPULoadNotified != true) do={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "abacus,chart-increasing" ] . "Health warning: CPU load"); \
@@ -59,6 +62,23 @@ $ScriptLock $0;
:set CheckHealthCPULoadNotified false;
}
+:local CheckHealthFreeRAM ($Resource->"free-memory" * 100 / $Resource->"total-memory");
+:if ($CheckHealthFreeRAM < 20 && $CheckHealthFreeRAMNotified != true) do={
+ $SendNotification2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "card-file-box,chart-decreasing" ] . "Health warning: free RAM"); \
+ message=("The available free RAM on " . $Identity . " is at " . $CheckHealthFreeRAM . "% (" . \
+ ($Resource->"free-memory" / 1024 / 1024) . "MiB)!") });
+ :set CheckHealthFreeRAMNotified true;
+}
+:if ($CheckHealthFreeRAM > 30 && $CheckHealthFreeRAMNotified = true) do={
+ $SendNotification2 ({ origin=$0; \
+ subject=([ $SymbolForNotification "card-file-box,chart-increasing" ] . "Health recovery: free RAM"); \
+ message=("The available free RAM on " . $Identity . " increased to " . $CheckHealthFreeRAM . "% (" . \
+ ($Resource->"free-memory" / 1024 / 1024) . "MiB).") });
+ :set CheckHealthFreeRAMNotified 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 ];