From 63ca79b960c30e38eecc9fab9e295d0845663db6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 28 Aug 2019 20:48:32 +0200 Subject: check-health: check for valid psu state data This is required with recovery notifications --- check-health | 21 ++++++++++++--------- 1 file 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!"); + } } } -- cgit v1.2.3-54-g00ecf