check-health: use $SymbolByUnicodeName

This commit is contained in:
Christian Hesse 2020-07-17 07:41:47 +02:00
parent 7862ce5f19
commit 17e9635ca1

View file

@ -13,6 +13,7 @@
:global LogPrintExit;
:global SendNotification;
:global SymbolByUnicodeName;
:local FormatVoltage do={
:local Voltage [ :tonum $1 ];
@ -26,7 +27,7 @@
[ :typeof ($CheckHealthCurrent->$Voltage) ] = "num") do={
:if ($CheckHealthLast->$Voltage * (100 + $CheckHealthVoltagePercent) < $CheckHealthCurrent->$Voltage * 100 || \
$CheckHealthLast->$Voltage * 100 > $CheckHealthCurrent->$Voltage * (100 + $CheckHealthVoltagePercent)) do={
$SendNotification ("\E2\9A\A1 Health warning: " . $Voltage) \
$SendNotification ([ $SymbolByUnicodeName "high-voltage-sign" ] . " Health warning: " . $Voltage) \
("The " . $Voltage . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
"old value: " . [ $FormatVoltage ($CheckHealthLast->$Voltage) ] . "\n" . \
"new value: " . [ $FormatVoltage ($CheckHealthCurrent->$Voltage) ]);
@ -39,12 +40,12 @@
[ :typeof ($CheckHealthCurrent->($PSU . "-state")) ] = "str") do={
:if ($CheckHealthLast->($PSU . "-state") = "ok" && \
$CheckHealthCurrent->($PSU . "-state") != "ok") do={
$SendNotification ("\E2\9D\8C Health warning: " . $PSU . " state") \
$SendNotification ([ $SymbolByUnicodeName "cross-mark" ] . " Health warning: " . $PSU . " state") \
("The power supply unit '" . $PSU . "' on " . $Identity . " failed!");
}
:if ($CheckHealthLast->($PSU . "-state") != "ok" && \
$CheckHealthCurrent->($PSU . "-state") = "ok") do={
$SendNotification ("\E2\9C\85 Health recovery: " . $PSU . " state") \
$SendNotification ([ $SymbolByUnicodeName "white-heavy-check-mark" ] . " Health recovery: " . $PSU . " state") \
("The power supply unit '" . $PSU . "' on " . $Identity . " recovered!");
}
}
@ -59,13 +60,13 @@
}
:if ($CheckHealthLast->$Temperature <= $CheckHealthTemperature->$Temperature && \
$CheckHealthCurrent->$Temperature > $CheckHealthTemperature->$Temperature) do={
$SendNotification ("\F0\9F\94\A5 Health warning: " . $Temperature) \
$SendNotification ([ $SymbolByUnicodeName "fire" ] . " Health warning: " . $Temperature) \
("The " . $Temperature . " on " . $Identity . " is above threshold: " . \
$CheckHealthCurrent->$Temperature . "\C2\B0" . "C");
}
:if ($CheckHealthLast->$Temperature > $CheckHealthTemperature->$Temperature && \
$CheckHealthCurrent->$Temperature <= $CheckHealthTemperature->$Temperature) do={
$SendNotification ("\E2\9C\85 Health recovery: " . $Temperature) \
$SendNotification ([ $SymbolByUnicodeName "white-heavy-check-mark" ] . " Health recovery: " . $Temperature) \
("The " . $Temperature . " on " . $Identity . " dropped below threshold: " . \
$CheckHealthCurrent->$Temperature . "\C2\B0" . "C");
}