Return correct SMART status

This commit is contained in:
Ely Deckers 2022-02-21 09:52:29 +01:00
parent 62882ab8fe
commit 15e6ad239b
1 changed files with 8 additions and 5 deletions

View File

@ -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);