From 75bd14267e7a5507e0d58b9945dbb24e5d831af8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 20 Jan 2023 14:24:20 +0100 Subject: check-health: monitor CPU load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ---- ✂️ ---- 🧮️📈️ Health warning: CPU load The average CPU load on MikroTik is at 76%! ---- ✂️ ---- 🧮️📉️ Health recovery: CPU load The average CPU load on MikroTik decreased to 64%. ---- ✂️ ---- --- check-health | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'check-health') diff --git a/check-health b/check-health index e754d69..3957ad1 100644 --- a/check-health +++ b/check-health @@ -10,6 +10,8 @@ :global GlobalFunctionsReady; :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } +:global CheckHealthCPULoad; +:global CheckHealthCPULoadNotified; :global CheckHealthLast; :global CheckHealthTemperature; :global CheckHealthTemperatureDeviation; @@ -43,6 +45,20 @@ $ScriptLock $0; +:set CheckHealthCPULoad (($CheckHealthCPULoad * 4 + [ /system/resource/get cpu-load ] * 10) / 5); +:if ($CheckHealthCPULoad > 750 && $CheckHealthCPULoadNotified != true) do={ + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "abacus,chart-increasing" ] . "Health warning: CPU load"); \ + message=("The average CPU load on " . $Identity . " is at " . ($CheckHealthCPULoad / 10) . "%!") }); + :set CheckHealthCPULoadNotified true; +} +:if ($CheckHealthCPULoad < 650 && $CheckHealthCPULoadNotified = true) do={ + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "abacus,chart-decreasing" ] . "Health recovery: CPU load"); \ + message=("The average CPU load on " . $Identity . " decreased to " . ($CheckHealthCPULoad / 10) . "%.") }); + :set CheckHealthCPULoadNotified 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-54-g00ecf