aboutsummaryrefslogtreecommitdiffstats
path: root/check-health.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-10-24 16:26:14 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-10-24 17:03:12 +0200
commitff35f0c87f4dc9ea75b2e911d9cb397ab2c120f7 (patch)
tree7a89d42da1b24ea662c9a2171ad21400a7ce7944 /check-health.rsc
parentd4e5194a65b5a40ce458382d28b8af45086b80f7 (diff)
check-health: reverse logic for RAM (free -> utilization)...
... 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%. ---- ✂️ ----
Diffstat (limited to 'check-health.rsc')
-rw-r--r--check-health.rsc25
1 files changed, 13 insertions, 12 deletions
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={