From 584b480d86cab56328e44a60d41311af8d3197c6 Mon Sep 17 00:00:00 2001 From: 1234Erwan <84467245+1234Erwan@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:27:35 +0200 Subject: [PATCH] Update smartctl.py Signed-off-by: 1234Erwan <84467245+1234Erwan@users.noreply.github.com> --- SOURCES/etc/xapi.d/plugins/smartctl.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/SOURCES/etc/xapi.d/plugins/smartctl.py b/SOURCES/etc/xapi.d/plugins/smartctl.py index 435ede9..aae1d22 100755 --- a/SOURCES/etc/xapi.d/plugins/smartctl.py +++ b/SOURCES/etc/xapi.d/plugins/smartctl.py @@ -20,29 +20,25 @@ def _list_devices(): @error_wrapped def get_information(session, args): results = {} - i = 0 with OperationLocker(): devices = _list_devices() for device in devices: - cmd = run_command(["smartctl", "-j", "-a", "-d", devices[i]['name'], devices[i]['type']], check=False) + cmd = run_command(["smartctl", "-j", "-a", "-d", device['name'], device['type']], check=False) results[device] = json.loads(cmd['stdout']) - i = i + 1 return json.dumps(results) @error_wrapped def get_health(session, args): results = {} - i = 0 with OperationLocker(): devices = _list_devices() for device in devices: - cmd = run_command(["smartctl", "-j", "-H", "-d", devices[i]['name'], devices[i]['type']]) + cmd = run_command(["smartctl", "-j", "-H", "-d", device['name'], device['type']], check=False) json_output = json.loads(cmd['stdout']) if json_output['smart_status']['passed']: results[disk] = "PASSED" else: results[disk] = "FAILED" - i = i + 1 return json.dumps(results)