From 15e6ad239bb8aa602cf595d30b1ab31cfa6419f6 Mon Sep 17 00:00:00 2001 From: Ely Deckers Date: Mon, 21 Feb 2022 09:52:29 +0100 Subject: [PATCH] Return correct SMART status --- pfsense_zbx.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pfsense_zbx.php b/pfsense_zbx.php index d3400b9..ee7424d 100644 --- a/pfsense_zbx.php +++ b/pfsense_zbx.php @@ -893,12 +893,15 @@ class Command /^SMART Health Status/ {print $2;exit}'")), PfEnv::get_smart_drive_list()); - $maybe_not_ok = Util::array_first($dev_states, function ($dev_state) { - $is_ok = - array_key_exists($dev_state, SMART_DEV_STATUS) && - SMART_DEV_STATUS[$dev_state] == SMART_OK; + $smart_states = + array_map( + fn($dev_state) => array_key_exists($dev_state, SMART_DEV_STATUS) ? + SMART_DEV_STATUS[$dev_state] : + SMART_ERROR, + $dev_states); - return !$is_ok; + $maybe_not_ok = Util::array_first($smart_states, function ($smart_state) { + return $smart_state != SMART_OK; }); return Util::result($maybe_not_ok ?: SMART_OK);