health=$(smartctl -H "$path" 2>/dev/null | grep -iE "SMART overall-health|SMART Health Status"| sed 's/.*: *//')
if[ -z "$health"];then
echo -e " Health: ${YW}SMART not available for this device${CL}"
elifecho"$health"| grep -qiE "PASSED|OK";then
echo -e " Health: ${GN}${health}${CL}"
else
echo -e " Health: ${RD}${health}${CL}"
fi
if[["$dev"== nvme* ]];then
local a
a=$(smartctl -A "$path" 2>/dev/null)
echo"$a"| grep -iE "Temperature:|Available Spare:|Percentage Used:|Data Units Written:|Power On Hours:|Unsafe Shutdowns:|Media and Data Integrity Errors:"|
echo -e "${YW}Scanning ${#DISKS[@]} disk(s) for SMART health...${CL}"
for d in "${DISKS[@]}";do
report_disk "$d"
done
echo
# Offer an optional, non-destructive short self-test
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "SMART Self-Test"\
--yesno "Health report complete.\n\nDo you want to start a non-destructive SHORT SMART self-test on a disk?\n\n(The test runs in the background; check results later with: smartctl -a /dev/XXX)"14 70;then
TEST_MENU=()
for d in "${DISKS[@]}";do
TEST_MENU+=("$d""/dev/$d""OFF")
done
sel=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Select Disk for Short Self-Test"\
--radiolist "\nSelect a disk:\n"16606"${TEST_MENU[@]}" 3>&1 1>&2 2>&3| tr -d '"')
if[ -n "$sel"];then
msg_info "Starting short self-test on /dev/$sel"
if smartctl -t short "/dev/$sel"&>/dev/null;then
msg_ok "Short self-test started on /dev/$sel"
echo -e "${YW}Check progress/result with: ${GN}smartctl -a /dev/$sel${CL}"
else
msg_error "Could not start self-test on /dev/$sel"
fi
fi
fi
echo -e "\n${GN}Disk health check complete.${CL}\n"