diff options
author | Christian Hesse <mail@eworm.de> | 2023-10-24 16:26:14 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-10-24 17:03:12 +0200 |
commit | ff35f0c87f4dc9ea75b2e911d9cb397ab2c120f7 (patch) | |
tree | 7a89d42da1b24ea662c9a2171ad21400a7ce7944 | |
parent | d4e5194a65b5a40ce458382d28b8af45086b80f7 (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%.
---- ✂️ ----
-rw-r--r-- | check-health.rsc | 25 | ||||
-rw-r--r-- | doc/check-health.d/notification-03-free-ram-low.avif | bin | 6457 -> 0 bytes | |||
-rw-r--r-- | doc/check-health.d/notification-03-ram-utilization-high.avif | bin | 0 -> 7527 bytes | |||
-rw-r--r-- | doc/check-health.d/notification-04-free-ram-ok.avif | bin | 6772 -> 0 bytes | |||
-rw-r--r-- | doc/check-health.d/notification-04-ram-utilization-ok.avif | bin | 0 -> 6637 bytes | |||
-rw-r--r-- | doc/check-health.md | 14 |
6 files changed, 20 insertions, 19 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={ diff --git a/doc/check-health.d/notification-03-free-ram-low.avif b/doc/check-health.d/notification-03-free-ram-low.avif Binary files differdeleted file mode 100644 index effc87c..0000000 --- a/doc/check-health.d/notification-03-free-ram-low.avif +++ /dev/null diff --git a/doc/check-health.d/notification-03-ram-utilization-high.avif b/doc/check-health.d/notification-03-ram-utilization-high.avif Binary files differnew file mode 100644 index 0000000..59155c5 --- /dev/null +++ b/doc/check-health.d/notification-03-ram-utilization-high.avif diff --git a/doc/check-health.d/notification-04-free-ram-ok.avif b/doc/check-health.d/notification-04-free-ram-ok.avif Binary files differdeleted file mode 100644 index cadb1d0..0000000 --- a/doc/check-health.d/notification-04-free-ram-ok.avif +++ /dev/null diff --git a/doc/check-health.d/notification-04-ram-utilization-ok.avif b/doc/check-health.d/notification-04-ram-utilization-ok.avif Binary files differnew file mode 100644 index 0000000..d995b9a --- /dev/null +++ b/doc/check-health.d/notification-04-ram-utilization-ok.avif diff --git a/doc/check-health.md b/doc/check-health.md index 34b5faf..3bde4e9 100644 --- a/doc/check-health.md +++ b/doc/check-health.md @@ -13,7 +13,7 @@ This script is run from scheduler periodically, sending notification on health related events: * high CPU utilization -* low available free RAM +* high RAM utilization (low available RAM) * voltage jumps up or down more than configured threshold * voltage drops below hard lower limit * power supply failed or recovered @@ -21,9 +21,9 @@ health related events: Note that bad initial state will not trigger an event. -Monitoring CPU utilization and available free RAM works on all devices. -Other than that only sensors available in hardware can be checked. See what -your hardware supports: +Monitoring CPU and RAM utilization (available processing and memory +resources) works on all devices. Other than that only sensors available +in hardware can be checked. See what your hardware supports: /system/health/print; @@ -34,10 +34,10 @@ your hardware supports: ![check-health notification cpu utilization high](check-health.d/notification-01-cpu-utilization-high.avif) ![check-health notification cpu utilization ok](check-health.d/notification-02-cpu-utilization-ok.avif) -#### Available free RAM +#### RAM utilization (low available RAM) -![check-health notification free ram low](check-health.d/notification-03-free-ram-low.avif) -![check-health notification free ram ok](check-health.d/notification-04-free-ram-ok.avif) +![check-health notification ram utilization high](check-health.d/notification-03-ram-utilization-high.avif) +![check-health notification ram utilization ok](check-health.d/notification-04-ram-utilization-ok.avif) #### Voltage |