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
|
||||
|
||||
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:
|
||||
return None
|
||||
|
||||
# Strip partition suffix
|
||||
base_device = re.sub(r'p?\d+$', '', device_path)
|
||||
# Determine device type
|
||||
tran = run_command(f"lsblk -no tran {device_path}", host=hostname)
|
||||
tran = tran.strip() if tran else ""
|
||||
|
||||
# Detect type: NVMe or SATA
|
||||
if 'nvme' in base_device:
|
||||
dev_type = 'nvme'
|
||||
if tran == "nvme":
|
||||
cmd = f"sudo smartctl -a -j {device_path} -d nvme 2>/dev/null"
|
||||
elif tran == "sata":
|
||||
cmd = f"sudo smartctl -a -j {device_path} 2>/dev/null"
|
||||
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)
|
||||
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
|
||||
|
||||
def get_device_health(osd_id, hostname):
|
||||
|
||||
Reference in New Issue
Block a user