Merge pull request #596 from martindoublem/smartstatus

[smartstatus] Added support for nvme SSDs
This commit is contained in:
tobi-wan-kenobi 2020-04-10 16:41:55 +02:00 committed by GitHub
commit 3a376a4ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,13 +84,15 @@ class Module(bumblebee.engine.Module):
for (root, folders, files) in os.walk('/dev'): for (root, folders, files) in os.walk('/dev'):
if root == '/dev': if root == '/dev':
devices = {"".join(filter(lambda i: i.isdigit() == False, file)) for file in files if 'sd' in file} devices = {"".join(filter(lambda i: i.isdigit() == False, file)) for file in files if 'sd' in file}
nvme = {file for file in files if('nvme0n' in file and 'p' not in file)}
devices.update(nvme)
return devices return devices
def smart(self, disk_name): def smart(self, disk_name):
SMARTCTL_PATH = which('smartctl') SMARTCTL_PATH = which('smartctl')
assessment = None assessment = None
cmd = Popen( cmd = Popen(
['sudo', SMARTCTL_PATH, '--health', os.path.join('/dev/', disk_name.replace('nvd','nvme'))], ['sudo', SMARTCTL_PATH, '--health', os.path.join('/dev/', disk_name)],
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
) )
@ -105,7 +107,7 @@ class Module(bumblebee.engine.Module):
if assessment == 'OK': if assessment == 'OK':
cmd = Popen( cmd = Popen(
['sudo', SMARTCTL_PATH, '-A', os.path.join('/dev/', disk_name.replace('nvd','nvme'))], ['sudo', SMARTCTL_PATH, '-A', os.path.join('/dev/', disk_name)],
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
) )