Added workaround for MX500 SSD issues
This commit is contained in:
parent
c3500ee324
commit
3c5f9c1bbe
1 changed files with 26 additions and 13 deletions
|
|
@ -22,6 +22,7 @@ TOP_PANE_TEXT = TOP_PANE_TEXT.format(**COLORS)
|
||||||
|
|
||||||
# Regex
|
# Regex
|
||||||
REGEX_ERROR_STATUS = re.compile('|'.join(STATUSES['RED']))
|
REGEX_ERROR_STATUS = re.compile('|'.join(STATUSES['RED']))
|
||||||
|
REGEX_MX500 = re.compile(r'CT(250|500|1000|2000)MX500SSD(1|4)', re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
# Error Classes
|
# Error Classes
|
||||||
|
|
@ -87,6 +88,7 @@ class CpuObj():
|
||||||
class DiskObj():
|
class DiskObj():
|
||||||
"""Object for tracking disk specific data."""
|
"""Object for tracking disk specific data."""
|
||||||
def __init__(self, disk_path):
|
def __init__(self, disk_path):
|
||||||
|
self.attributes = {}
|
||||||
self.checkbox = None
|
self.checkbox = None
|
||||||
self.attr_type = 'UNKNOWN'
|
self.attr_type = 'UNKNOWN'
|
||||||
self.disk_ok = True
|
self.disk_ok = True
|
||||||
|
|
@ -119,6 +121,13 @@ class DiskObj():
|
||||||
self.get_smart_details()
|
self.get_smart_details()
|
||||||
self.description = '{size} ({tran}) {model} {serial}'.format(
|
self.description = '{size} ({tran}) {model} {serial}'.format(
|
||||||
**self.lsblk)
|
**self.lsblk)
|
||||||
|
self.update_attributes()
|
||||||
|
|
||||||
|
def update_attributes(self):
|
||||||
|
"""HACK to adjust attribute thresholds for Crucial MX500 SSDs."""
|
||||||
|
self.attributes = ATTRIBUTES.copy()
|
||||||
|
if REGEX_MX500.search(self.lsblk['model']):
|
||||||
|
self.attributes['SMART'][197].update({'Warning': 1, 'Error': 2})
|
||||||
|
|
||||||
def add_nvme_smart_note(self, note):
|
def add_nvme_smart_note(self, note):
|
||||||
"""Add note that will be included in the NVMe / SMART report."""
|
"""Add note that will be included in the NVMe / SMART report."""
|
||||||
|
|
@ -189,8 +198,8 @@ class DiskObj():
|
||||||
elif self.smart_attributes:
|
elif self.smart_attributes:
|
||||||
poh = self.smart_attributes.get(9, {}).get('raw', -1)
|
poh = self.smart_attributes.get(9, {}).get('raw', -1)
|
||||||
|
|
||||||
error_thresh = ATTRIBUTES['SMART'][9]['Error']
|
error_thresh = self.attributes['SMART'][9]['Error']
|
||||||
max_thresh = ATTRIBUTES['SMART'][9]['Maximum']
|
max_thresh = self.attributes['SMART'][9]['Maximum']
|
||||||
|
|
||||||
return error_thresh <= poh < max_thresh
|
return error_thresh <= poh < max_thresh
|
||||||
|
|
||||||
|
|
@ -211,23 +220,23 @@ class DiskObj():
|
||||||
elif self.smart_attributes:
|
elif self.smart_attributes:
|
||||||
items = self.smart_attributes.items()
|
items = self.smart_attributes.items()
|
||||||
for k, v in items:
|
for k, v in items:
|
||||||
if k in ATTRIBUTES[attr_type]:
|
if k in self.attributes[attr_type]:
|
||||||
if not ATTRIBUTES[attr_type][k]['Error']:
|
if not self.attributes[attr_type][k]['Error']:
|
||||||
# Informational attribute, skip
|
# Informational attribute, skip
|
||||||
continue
|
continue
|
||||||
if ATTRIBUTES[attr_type][k]['Ignore']:
|
if self.attributes[attr_type][k]['Ignore']:
|
||||||
# Attribute is non-failing, skip
|
# Attribute is non-failing, skip
|
||||||
continue
|
continue
|
||||||
if v['raw'] >= ATTRIBUTES[attr_type][k]['Error']:
|
if v['raw'] >= self.attributes[attr_type][k]['Error']:
|
||||||
if (ATTRIBUTES[attr_type][k]['Maximum']
|
if (self.attributes[attr_type][k]['Maximum']
|
||||||
and v['raw'] >= ATTRIBUTES[attr_type][k]['Maximum']):
|
and v['raw'] >= self.attributes[attr_type][k]['Maximum']):
|
||||||
# Non-standard value, skip
|
# Non-standard value, skip
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
disk_ok = False
|
disk_ok = False
|
||||||
|
|
||||||
# Disable override if necessary
|
# Disable override if necessary
|
||||||
if ATTRIBUTES[attr_type][k].get('Critical', False):
|
if self.attributes[attr_type][k].get('Critical', False):
|
||||||
self.override_disabled = True
|
self.override_disabled = True
|
||||||
|
|
||||||
# SMART overall assessment
|
# SMART overall assessment
|
||||||
|
|
@ -298,7 +307,7 @@ class DiskObj():
|
||||||
attr_type = 'SMART'
|
attr_type = 'SMART'
|
||||||
items = self.smart_attributes.items()
|
items = self.smart_attributes.items()
|
||||||
for k, v in items:
|
for k, v in items:
|
||||||
if k in ATTRIBUTES[attr_type]:
|
if k in self.attributes[attr_type]:
|
||||||
_note = ''
|
_note = ''
|
||||||
_color = COLORS['GREEN']
|
_color = COLORS['GREEN']
|
||||||
|
|
||||||
|
|
@ -308,19 +317,23 @@ class DiskObj():
|
||||||
else:
|
else:
|
||||||
_line = ' {i:>3} / {h}: {n:28}'.format(
|
_line = ' {i:>3} / {h}: {n:28}'.format(
|
||||||
i=k,
|
i=k,
|
||||||
h=ATTRIBUTES[attr_type][k]['Hex'],
|
h=self.attributes[attr_type][k]['Hex'],
|
||||||
n=v['name'][:28])
|
n=v['name'][:28])
|
||||||
|
|
||||||
# Set color
|
# Set color
|
||||||
for _t, _c in ATTRIBUTE_COLORS:
|
for _t, _c in ATTRIBUTE_COLORS:
|
||||||
if ATTRIBUTES[attr_type][k][_t]:
|
if self.attributes[attr_type][k][_t]:
|
||||||
if v['raw'] >= ATTRIBUTES[attr_type][k][_t]:
|
if v['raw'] >= self.attributes[attr_type][k][_t]:
|
||||||
_color = COLORS[_c]
|
_color = COLORS[_c]
|
||||||
if _t == 'Error':
|
if _t == 'Error':
|
||||||
_note = '(failed)'
|
_note = '(failed)'
|
||||||
elif _t == 'Maximum':
|
elif _t == 'Maximum':
|
||||||
_note = '(invalid?)'
|
_note = '(invalid?)'
|
||||||
|
|
||||||
|
# 197/C5 warning
|
||||||
|
if str(k) == '197' and REGEX_MX500.search(self.lsblk['model']):
|
||||||
|
_note = '(MX500 thresholds)'
|
||||||
|
|
||||||
# 199/C7 warning
|
# 199/C7 warning
|
||||||
if str(k) == '199' and v['raw'] > 0:
|
if str(k) == '199' and v['raw'] > 0:
|
||||||
_note = '(bad cable?)'
|
_note = '(bad cable?)'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue