check-health: check for valid psu state data

This is required with recovery notifications
This commit is contained in:
Christian Hesse 2019-08-28 20:48:32 +02:00
parent b74d465cd0
commit 63ca79b960

View file

@ -31,15 +31,18 @@
} }
:foreach PSU in={ "psu1"; "psu2" } do={ :foreach PSU in={ "psu1"; "psu2" } do={
:if ($CheckHealthLast->($PSU . "-state") = "ok" && \ :if ([ :typeof ($CheckHealthLast->($PSU . "-state")) ] = "str" && \
$CheckHealthCurrent->($PSU . "-state") != "ok") do={ [ :typeof ($CheckHealthCurrent->($PSU . "-state")) ] = "str") do={
$SendNotification ("Health warning: " . $PSU . " state") \ :if ($CheckHealthLast->($PSU . "-state") = "ok" && \
("The power supply unit '" . $PSU . "' on " . $Identity . " failed!"); $CheckHealthCurrent->($PSU . "-state") != "ok") do={
} $SendNotification ("Health warning: " . $PSU . " state") \
:if ($CheckHealthLast->($PSU . "-state") != "ok" && \ ("The power supply unit '" . $PSU . "' on " . $Identity . " failed!");
$CheckHealthCurrent->($PSU . "-state") = "ok") do={ }
$SendNotification ("Health recovery: " . $PSU . " state") \ :if ($CheckHealthLast->($PSU . "-state") != "ok" && \
("The power supply unit '" . $PSU . "' on " . $Identity . " recovered!"); $CheckHealthCurrent->($PSU . "-state") = "ok") do={
$SendNotification ("Health recovery: " . $PSU . " state") \
("The power supply unit '" . $PSU . "' on " . $Identity . " recovered!");
}
} }
} }