diff options
-rw-r--r-- | check-health | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/check-health b/check-health index 7c7f169..8cfe47a 100644 --- a/check-health +++ b/check-health @@ -31,15 +31,18 @@ } :foreach PSU in={ "psu1"; "psu2" } do={ - :if ($CheckHealthLast->($PSU . "-state") = "ok" && \ - $CheckHealthCurrent->($PSU . "-state") != "ok") do={ - $SendNotification ("Health warning: " . $PSU . " state") \ - ("The power supply unit '" . $PSU . "' on " . $Identity . " failed!"); - } - :if ($CheckHealthLast->($PSU . "-state") != "ok" && \ - $CheckHealthCurrent->($PSU . "-state") = "ok") do={ - $SendNotification ("Health recovery: " . $PSU . " state") \ - ("The power supply unit '" . $PSU . "' on " . $Identity . " recovered!"); + :if ([ :typeof ($CheckHealthLast->($PSU . "-state")) ] = "str" && \ + [ :typeof ($CheckHealthCurrent->($PSU . "-state")) ] = "str") do={ + :if ($CheckHealthLast->($PSU . "-state") = "ok" && \ + $CheckHealthCurrent->($PSU . "-state") != "ok") do={ + $SendNotification ("Health warning: " . $PSU . " state") \ + ("The power supply unit '" . $PSU . "' on " . $Identity . " failed!"); + } + :if ($CheckHealthLast->($PSU . "-state") != "ok" && \ + $CheckHealthCurrent->($PSU . "-state") = "ok") do={ + $SendNotification ("Health recovery: " . $PSU . " state") \ + ("The power supply unit '" . $PSU . "' on " . $Identity . " recovered!"); + } } } |