seperate smartctl depending on device class
This commit is contained in:
@@ -122,23 +122,26 @@ def get_device_path_for_osd(osd_id, hostname):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_smart_data_remote(device_path, hostname):
|
def get_smart_data_remote(device_path, hostname):
|
||||||
"""Get SMART data from a remote host with proper device type detection."""
|
"""Get SMART data from a remote host"""
|
||||||
if not device_path:
|
if not device_path:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Strip partition suffix
|
# Determine device type
|
||||||
base_device = re.sub(r'p?\d+$', '', device_path)
|
tran = run_command(f"lsblk -no tran {device_path}", host=hostname)
|
||||||
|
tran = tran.strip() if tran else ""
|
||||||
|
|
||||||
# Detect type: NVMe or SATA
|
if tran == "nvme":
|
||||||
if 'nvme' in base_device:
|
cmd = f"sudo smartctl -a -j {device_path} -d nvme 2>/dev/null"
|
||||||
dev_type = 'nvme'
|
elif tran == "sata":
|
||||||
|
cmd = f"sudo smartctl -a -j {device_path} 2>/dev/null"
|
||||||
else:
|
else:
|
||||||
dev_type = 'sat' # sata/ata, compatible with SSD/HDD
|
cmd = f"sudo smartctl -a -j {device_path} 2>/dev/null"
|
||||||
|
|
||||||
cmd = f"sudo smartctl -a -j -d {dev_type} {base_device} 2>/dev/null"
|
|
||||||
result = run_command(cmd, host=hostname, parse_json=True)
|
result = run_command(cmd, host=hostname, parse_json=True)
|
||||||
if DEBUG and result is None:
|
|
||||||
print(f"{Colors.YELLOW}DEBUG: SMART data failed for {base_device} on {hostname}{Colors.END}")
|
if not result and DEBUG:
|
||||||
|
print(f"{Colors.RED}DEBUG: SMART data failed for {device_path} on {hostname}{Colors.END}")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_device_health(osd_id, hostname):
|
def get_device_health(osd_id, hostname):
|
||||||
|
|||||||
Reference in New Issue
Block a user