Skip to content

Commit

Permalink
Update smartctl.py
Browse files Browse the repository at this point in the history
Signed-off-by: 1234Erwan <[email protected]>
  • Loading branch information
1234Erwan authored Oct 25, 2024
1 parent d0153b9 commit 584b480
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions SOURCES/etc/xapi.d/plugins/smartctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 584b480

Please sign in to comment.