From ff35f0c87f4dc9ea75b2e911d9cb397ab2c120f7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 24 Oct 2023 16:26:14 +0200 Subject: check-health: reverse logic for RAM (free -> utilization)... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... to bring it in sync with CPU utilization. Also make the output more verbose, at least for the warning. ---- ✂️ ---- 🗃️📈️ Health warning: RAM utilization The RAM utilization on MikroTik is at 81%! total: 64 MiB used: 52 MiB free: 11 MiB ---- ✂️ ---- 🗃️📉️ Health recovery: RAM utilization The RAM utilization on MikroTik decreased to 65%. ---- ✂️ ---- --- check-health.rsc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'check-health.rsc') diff --git a/check-health.rsc b/check-health.rsc index af0d70b..3ada4c8 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -12,8 +12,8 @@ :global CheckHealthCPUUtilization; :global CheckHealthCPUUtilizationNotified; -:global CheckHealthFreeRAMNotified; :global CheckHealthLast; +:global CheckHealthRAMUtilizationNotified; :global CheckHealthTemperature; :global CheckHealthTemperatureDeviation; :global CheckHealthTemperatureNotified; @@ -52,20 +52,21 @@ $ScriptLock $0; :set CheckHealthCPUUtilizationNotified false; } -:local CheckHealthFreeRAM ($Resource->"free-memory" * 100 / $Resource->"total-memory"); -:if ($CheckHealthFreeRAM < 20 && $CheckHealthFreeRAMNotified != true) do={ +:local CheckHealthRAMUtilization (($Resource->"total-memory" - $Resource->"free-memory") * 100 / $Resource->"total-memory"); +:if ($CheckHealthRAMUtilization >=80 && $CheckHealthRAMUtilizationNotified != 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; + subject=([ $SymbolForNotification "card-file-box,chart-increasing" ] . "Health warning: RAM utilization"); \ + message=("The RAM utilization on " . $Identity . " is at " . $CheckHealthRAMUtilization . "%!\n\n" . \ + [ $FormatLine "total" (($Resource->"total-memory" / 1024 / 1024) . " MiB") ] . "\n" . \ + [ $FormatLine "used" ((($Resource->"total-memory" - $Resource->"free-memory") / 1024 / 1024) . " MiB") ] . "\n" . \ + [ $FormatLine "free" (($Resource->"free-memory" / 1024 / 1024) . " MiB") ]) }); + :set CheckHealthRAMUtilizationNotified true; } -:if ($CheckHealthFreeRAM > 30 && $CheckHealthFreeRAMNotified = true) do={ +:if ($CheckHealthRAMUtilization < 70 && $CheckHealthRAMUtilizationNotified = 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; + subject=([ $SymbolForNotification "card-file-box,chart-decreasing" ] . "Health recovery: RAM utilization"); \ + message=("The RAM utilization on " . $Identity . " decreased to " . $CheckHealthRAMUtilization . "%.") }); + :set CheckHealthRAMUtilizationNotified false; } :if ([ :len [ /system/health/find ] ] = 0) do={ -- cgit v1.2.3-54-g00ecf