From f40bb2c8c85adaa1ee84bb693b76a7a7e334f54a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 14 Oct 2019 19:06:21 +0200 Subject: check-health: make threshold for voltage configurable --- check-health | 7 ++++--- global-config | 6 ++++-- global-config-overlay | 2 +- global-config.changes | 1 + global-functions | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/check-health b/check-health index 8cfe47a..3b5c0de 100644 --- a/check-health +++ b/check-health @@ -6,6 +6,7 @@ :global CheckHealthLast; :global CheckHealthTemperature; +:global CheckHealthVoltagePercent; :global Identity; :global SendNotification; @@ -20,10 +21,10 @@ :foreach Voltage in={ "psu1-voltage"; "psu2-voltage"; "voltage" } do={ :if ([ :typeof ($CheckHealthLast->$Voltage) ] = "num" && \ [ :typeof ($CheckHealthCurrent->$Voltage) ] = "num") do={ - :if ($CheckHealthLast->$Voltage * 115 / 100 < $CheckHealthCurrent->$Voltage || \ - $CheckHealthLast->$Voltage * 100 / 115 > $CheckHealthCurrent->$Voltage) do={ + :if ($CheckHealthLast->$Voltage * (100 + $CheckHealthVoltagePercent) / 100 < $CheckHealthCurrent->$Voltage || \ + $CheckHealthLast->$Voltage * 100 / (100 + $CheckHealthVoltagePercent) > $CheckHealthCurrent->$Voltage) do={ $SendNotification ("Health warning: " . $Voltage) \ - ("The " . $Voltage . " on " . $Identity . " jumped more than 15%.\n\n" . \ + ("The " . $Voltage . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \ "old value: " . [ $FormatVoltage ($CheckHealthLast->$Voltage) ] . "\n" . \ "new value: " . [ $FormatVoltage ($CheckHealthCurrent->$Voltage) ]); } diff --git a/global-config b/global-config index 7a2787a..8089f83 100644 --- a/global-config +++ b/global-config @@ -6,7 +6,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 9; +:global GlobalConfigVersion 10; # This is used for DNS and backup file. :global Domain "example.com"; @@ -44,13 +44,15 @@ :global SafeUpdateUrl ""; #:global SafeUpdateUrl "https://example.com/ros/safe-update/"; -# These thresholds control when to send notification on temperature. +# These thresholds control when to send health notification +# on temperature and voltage. :global CheckHealthTemperature { temperature=50; cpu-temperature=70; board-temperature1=50; board-temperature2=50; } +:global CheckHealthVoltagePercent 15; # This controls what configuration is activated by bridge-port-to-default. :global BridgePortTo "default"; diff --git a/global-config-overlay b/global-config-overlay index c1971db..871aaa4 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -6,7 +6,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 9; +:global GlobalConfigVersion 10; # The global-config script is updated by script-updates, # global-config-overlay becomes an overlay for your changes. diff --git a/global-config.changes b/global-config.changes index 98c8a2c..bd8cac3 100644 --- a/global-config.changes +++ b/global-config.changes @@ -12,4 +12,5 @@ 7="introduced script 'check-health' with new configuration parameters"; 8="added donation hint and option to silence it"; 9="introduced configuration overlay 'global-config-overlay'"; + 10="make health threshold for voltage configurable"; }; diff --git a/global-functions b/global-functions index e50c61e..2336961 100644 --- a/global-functions +++ b/global-functions @@ -6,7 +6,7 @@ # global functions # expected configuration version -:global ExpectedConfigVersion 9; +:global ExpectedConfigVersion 10; # global variables not to be changed by user :global SentConfigChangesNotification "-"; -- cgit v1.2.3-54-g00ecf