diff --git a/roles/float-base/files/node-exporter-scripts/smartmon.py b/roles/float-base/files/node-exporter-scripts/smartmon.py index 3dd0c8f9ee6d6e99a4408de493d2861cf49f483d..8980e20d51409fd895cafd10eb6212a4fd8d0923 100644 --- a/roles/float-base/files/node-exporter-scripts/smartmon.py +++ b/roles/float-base/files/node-exporter-scripts/smartmon.py @@ -232,16 +232,13 @@ def device_smart_capabilities(device): (bool): True whenever SMART is available, False otherwise. (bool): True whenever SMART is enabled, False otherwise. """ - groups = device_info(device) - - state = { - g[1].split(' ', 1)[0] - for g in groups if g[0] == 'SMART support'} - - smart_available = 'Available' in state - smart_enabled = 'Enabled' in state - - return smart_available, smart_enabled + try: + subprocess.check_call( + ['/usr/sbin/smartctl', '--info'] + device.smartctl_select(), + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return True, True + except subprocess.CalledProcessError: + return False, False def collect_device_info(device):