From 2625cc09a5215c2f1f165197154a4c22f4ba6a3a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 13 Nov 2021 21:29:33 +0100 Subject: check-health: support hard lower limit for voltage ... to detect slow decrease of voltage, for example with UPS. --- check-health | 12 ++++++++++++ doc/check-health.md | 3 ++- global-config | 3 ++- global-config-overlay | 2 +- global-config.changes | 1 + global-functions | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/check-health b/check-health index 9fef8bc..56413c1 100644 --- a/check-health +++ b/check-health @@ -14,6 +14,7 @@ :global CheckHealthTemperature; :global CheckHealthTemperatureDeviation; :global CheckHealthTemperatureNotified; +:global CheckHealthVoltageLow; :global CheckHealthVoltagePercent; :global Identity; @@ -52,6 +53,17 @@ $ScriptLock $0; message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \ "old value: " . [ $FormatVoltage ($CheckHealthLast->$Name) ] . "\n" . \ "new value: " . [ $FormatVoltage $Voltage ]) }); + } else={ + :if ($Voltage <= $CheckHealthVoltageLow && $CheckHealthLast->$Name > $CheckHealthVoltageLow) do={ + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \ + message=("The " . $Name . " on " . $Identity . " dropped to " . [ $FormatVoltage $Voltage ] . " below hard limit.") }); + } + :if ($Voltage > $CheckHealthVoltageLow && $CheckHealthLast->$Name <= $CheckHealthVoltageLow) do={ + $SendNotification2 ({ origin=$0; \ + subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \ + message=("The " . $Name . " on " . $Identity . " recovered to " . [ $FormatVoltage $Voltage ] . " above hard limit.") }); + } } } } diff --git a/doc/check-health.md b/doc/check-health.md index 9e9e501..8e271d6 100644 --- a/doc/check-health.md +++ b/doc/check-health.md @@ -12,7 +12,7 @@ Description This script is run from scheduler periodically, sending notification on health related events: -* voltage jumps up or down more than configured threshold +* voltage jumps up or down more than configured threshold or drops below limit * power supply failed or recovered * temperature is above or below threshold @@ -53,6 +53,7 @@ Configuration The configuration goes to `global-config-overlay`, these are the parameters: * `CheckHealthTemperature`: an array specifying temperature thresholds for sensors +* `CheckHealthVoltageLow`: value (in volt*10) giving a hard lower limit * `CheckHealthVoltagePercent`: percentage value to trigger voltage jumps Also notification settings are required for e-mail, matrix and/or telegram. diff --git a/global-config b/global-config index 5f533b4..26e1a76 100644 --- a/global-config +++ b/global-config @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 68; +:global GlobalConfigVersion 69; # This is used for DNS and backup file. :global Domain "example.com"; @@ -105,6 +105,7 @@ } # This is deviation on recovery threshold against notification flooding. :global CheckHealthTemperatureDeviation 2; +:global CheckHealthVoltageLow 115; :global CheckHealthVoltagePercent 10; # Access-list entries matching this comment are updated diff --git a/global-config-overlay b/global-config-overlay index 4f8eee5..87abb87 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! # Comment or remove to disable news and change notifications. -:global GlobalConfigVersion 68; +:global GlobalConfigVersion 69; # Copy configuration from global-config here and modify it. diff --git a/global-config.changes b/global-config.changes index 2914ea9..a8198db 100644 --- a/global-config.changes +++ b/global-config.changes @@ -72,6 +72,7 @@ 66="Moved script 'bridge-port-to-default' to new module."; 67="Moved modules to directory with shorter name."; 68="Reintroduced 'global-wait' for functions in scheduler."; + 69="Support hard lower limit for voltage in 'check-health'."; }; # Migration steps to be applied on script updates diff --git a/global-functions b/global-functions index 19f5777..3ec3e3e 100644 --- a/global-functions +++ b/global-functions @@ -8,7 +8,7 @@ # https://git.eworm.de/cgit/routeros-scripts/about/ # expected configuration version -:global ExpectedConfigVersion 68; +:global ExpectedConfigVersion 69; # global variables not to be changed by user :global GlobalFunctionsReady false; -- cgit v1.2.3-70-g09d2