From ae42634a8e3f2209439ab66deca04fdf0570163e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Fri, 26 Mar 2021 00:57:08 -0600 Subject: [PATCH] Add SMART override for some Samsung devices * Addresses issue #163 --- scripts/wk/cfg/hw.py | 4 ++++ scripts/wk/hw/obj.py | 30 +++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/wk/cfg/hw.py b/scripts/wk/cfg/hw.py index 456cb08c..673d45f4 100644 --- a/scripts/wk/cfg/hw.py +++ b/scripts/wk/cfg/hw.py @@ -45,6 +45,10 @@ KNOWN_DISK_MODELS = { r'CT(250|500|1000|2000)MX500SSD(1|4)': { 197: {'Warning': 1, 'Error': 2, 'Note': '(MX500 thresholds)',}, }, + r'MZ(7|N)LN(128|256|512|1T0)HA(HQ|JQ|LR)-000H(1|7)': { + # Source: https://www.smartmontools.org/ticket/920 + 201: {'Error': 99, 'PercentageLife': True, 'Note': '(PM871b thresholds)'}, + }, } KNOWN_RAM_VENDOR_IDS = { # https://github.com/hewigovens/hewigovens.github.com/wiki/Memory-vendor-code diff --git a/scripts/wk/hw/obj.py b/scripts/wk/hw/obj.py index 63f958eb..d1f4dd33 100644 --- a/scripts/wk/hw/obj.py +++ b/scripts/wk/hw/obj.py @@ -210,7 +210,10 @@ class Disk(BaseObj): continue # Check attribute - if err_thresh <= value['raw'] < max_thresh: + if known_attributes[attr].get('PercentageLife', False): + if 0 <= value['raw'] <= err_thresh: + attributes_ok = False + elif err_thresh <= value['raw'] < max_thresh: attributes_ok = False # Done @@ -259,14 +262,23 @@ class Disk(BaseObj): label = f' {label.replace("_", " "):38}' # Value color - for threshold, color in ATTRIBUTE_COLORS: - threshold_val = known_attributes[attr].get(threshold, None) - if threshold_val and value['raw'] >= threshold_val: - value_color = color - if threshold == 'Error': - note = '(failed)' - elif threshold == 'Maximum': - note = '(invalid?)' + if known_attributes[attr].get('PercentageLife', False): + # PercentageLife values + if 0 <= value['raw'] <= known_attributes[attr]['Error']: + value_color = 'RED' + note = '(failed, % life remaining)' + elif value['raw'] < 0 or value['raw'] > 100: + value_color = 'PURPLE' + note = '(invalid?)' + else: + for threshold, color in ATTRIBUTE_COLORS: + threshold_val = known_attributes[attr].get(threshold, None) + if threshold_val and value['raw'] >= threshold_val: + value_color = color + if threshold == 'Error': + note = '(failed)' + elif threshold == 'Maximum': + note = '(invalid?)' # 199/C7 warning if str(attr) == '199' and value['raw'] > 0: