From 075077e5c5b1d8c88be2be5c261c289e329e1fe7 Mon Sep 17 00:00:00 2001 From: 1234Erwan <84467245+1234Erwan@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:25:09 +0200 Subject: [PATCH] Update smartctl.py Removed unnecessary lines from smartctl.py Signed-off-by: 1234Erwan <84467245+1234Erwan@users.noreply.github.com> --- SOURCES/etc/xapi.d/plugins/smartctl.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/SOURCES/etc/xapi.d/plugins/smartctl.py b/SOURCES/etc/xapi.d/plugins/smartctl.py index a835689..980b6f9 100755 --- a/SOURCES/etc/xapi.d/plugins/smartctl.py +++ b/SOURCES/etc/xapi.d/plugins/smartctl.py @@ -14,47 +14,36 @@ def _list_disks(): disks = [] result = run_command(['smartctl', '--scan']) for line in result['stdout'].splitlines(): + disks.append(line.split()[2]) disks.append(line.split()[0]) return disks -@error_wrapped -def _list_raids(): - raids = [] - result = run_command(['smartctl', '--scan']) - for line in result['stdout'].splitlines(): - raids.append(line.split()[2]) - return raids - @error_wrapped def get_information(session, args): results = {} - raids = {} i = 0 with OperationLocker(): disks = _list_disks() - raids = _list_raids() for disk in disks: - cmd = run_command(["smartctl", "-j", "-a", "-d", raids[i], disk], check=False) + cmd = run_command(["smartctl", "-j", "-a", "-d", disks[i], disks[i+1]], check=False) results[disk] = json.loads(cmd['stdout']) - i = i + 1 + i = i + 2 return json.dumps(results) @error_wrapped def get_health(session, args): results = {} - raids = {} i = 0 with OperationLocker(): disks = _list_disks() - raids = _list_raids() for disk in disks: - cmd = run_command(["smartctl", "-j", "-H", "-d", raids[i], disk]) + cmd = run_command(["smartctl", "-j", "-H", "-d", disks[i], disks[i+1]]) json_output = json.loads(cmd['stdout']) if json_output['smart_status']['passed']: results[disk] = "PASSED" else: results[disk] = "FAILED" - i = i + 1 + i = i + 2 return json.dumps(results)