check-health: make threshold for voltage configurable

This commit is contained in:
Christian Hesse 2019-10-14 19:06:21 +02:00
parent 09ce75c5b1
commit f40bb2c8c8
5 changed files with 11 additions and 7 deletions

View file

@ -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) ]);
}