Skip to content

Commit

Permalink
add todo entries and some comments for issue rockstor#997
Browse files Browse the repository at this point in the history
It seems some SMART reports, in this case from an lsi controller,
differs in formatting and content, this is causing smart to appear as
not available or enabled and even if this wasn't the case the reports
differ such that current parsing is challenged to find relevant entries.
  • Loading branch information
phillxnet committed Jan 1, 2016
1 parent 97ac482 commit aea63b0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/rockstor/system/smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def info(device):
#get smart info of the device, such as availability
o, e, rc = run_command([SMART, '-H', '--info', '/dev/%s' % device], throw=False)
res = {}
# todo add additional matching to account of eg some lsi formatting and name
# todo differences eg
# expected:- "SMART Health Status: OK"
# presented by lsi:- "SMART overall-health self-assessment test result: PASSED"
# Also note there are quite a few additional keys to look for here.
matches = ('Model Family:', 'Device Model:', 'Serial Number:',
'LU WWN Device Id:', 'Firmware Version:', 'User Capacity:',
'Sector Size:', 'Rotation Rate:', 'Device is:', 'ATA Version is:',
Expand Down Expand Up @@ -96,6 +101,8 @@ def capabilities(device):
return cap_d

def error_logs(device):
# todo provide path to parse very differently parsed info from from example
# todo some lsi controllers.
o, e, rc = run_command([SMART, '-l', 'error', '/dev/%s' % device],
throw=False)
# As we mute exceptions when calling the above command we should at least
Expand Down Expand Up @@ -163,6 +170,7 @@ def error_logs(device):
return (summary, log_l)

def test_logs(device):
# todo need to confirm this as working on lsi controller reports
o, e, rc = run_command([SMART, '-l', 'selftest', '-l', 'selective', '/dev/%s' % device])
test_d = {}
log_l = []
Expand All @@ -181,15 +189,22 @@ def test_logs(device):
return (test_d, log_l)

def run_test(device, test):
#start a smart test(short, long or conveyance)
# start a smart test(short, long or conveyance)
return run_command([SMART, '-t', test, '/dev/%s' % device])

def available(device):
#return true if SMART support is available on the device
"""
Returns boolean pair: true if SMART support is available on the device and
true if SMART support is enabled.
Used by update_disk_state in views/disk.py to assess smart status
:param device:
:return: available (boolean), enabled (boolean)
"""
o, e, rc = run_command([SMART, '--info', ('/dev/%s' % device)])
a = False
e = False
for i in o:
# todo Check on matching as sometimes multiple spaces after ":" ie on lsi9207
if (re.match('SMART support is: Available', i) is not None):
a = True
if (re.match('SMART support is: Enabled', i) is not None):
Expand All @@ -198,7 +213,7 @@ def available(device):

def toggle_smart(device, enable=False):
switch = 'on' if (enable) else 'off'
#enable SMART support of the device
# enable SMART support of the device
return run_command([SMART, '--smart=%s' % switch, '/dev/%s' % device])

def update_config(config):
Expand All @@ -208,7 +223,7 @@ def update_config(config):
with open(SMARTD_CONFIG) as sfo, open(npath, 'w') as tfo:
for line in sfo.readlines():
if (re.match('DEVICESCAN', line) is not None):
#comment out this line, if not, smartd ignores everything else
# comment out this line, if not, smartd ignores everything else
tfo.write('#%s' % line)
elif (re.match(ROCKSTOR_HEADER, line) is None):
tfo.write(line)
Expand Down

0 comments on commit aea63b0

Please sign in to comment.