diff options
author | Christian Hesse <mail@eworm.de> | 2019-08-28 20:48:32 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-08-28 20:48:32 +0200 |
commit | 63ca79b960c30e38eecc9fab9e295d0845663db6 (patch) | |
tree | 197efb83f661cf41a8acda3245ac33108274680c | |
parent | b74d465cd050dff793d44ceca78ce6e9745a016b (diff) |
check-health: check for valid psu state data
This is required with recovery notifications
-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!"); + } } } |