From 6780e1a24ccdefd3a328abe7ca8cef3d4ed57114 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 20 Jan 2023 14:34:18 +0100 Subject: check-health: monitor free RAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ---- ✂️ ---- 🗃️📉️ 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). ---- ✂️ ---- --- check-health | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'check-health') 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 ]; -- cgit v1.2.3-70-g09d2