Skip to content

Commit

Permalink
Update smartctl.py
Browse files Browse the repository at this point in the history
Removed unnecessary lines from smartctl.py

Signed-off-by: 1234Erwan <[email protected]>
  • Loading branch information
1234Erwan authored Aug 23, 2024
1 parent 2bd2eb8 commit 075077e
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions SOURCES/etc/xapi.d/plugins/smartctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 075077e

Please sign in to comment.