diff --git a/driveAtlas.sh b/driveAtlas.sh index 3e19761..80389ea 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -36,21 +36,21 @@ generate_10bay_layout() { for bay in {1..10}; do printf "┌──────────┐ " done - printf " │\n" + printf " │\n" # Bay contents printf "│ " for bay in {1..10}; do printf "│%-2d:%-7s│ " "$bay" "${DRIVE_MAP[$bay]:-EMPTY}" done - printf " │\n" + printf " │\n" # Bay bottom borders printf "│ " for bay in {1..10}; do printf "└──────────┘ " done - printf " │\n" + printf " │\n" printf "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n" } @@ -211,17 +211,32 @@ esac # Drive Details Section #------------------------------------------------------------------------------ -echo -e "\n=== Drive Details with SMART Status ===" -printf "%-15s %-10s %-8s %-8s %-8s %-30s %-20s\n" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" -echo "----------------------------------------------------------------------------------------------------------------------------" +echo -e "\n=== Drive Details with SMART Status (by Bay Position) ===" +printf "%-5s %-15s %-10s %-8s %-8s %-8s %-30s %-20s %-10s\n" "BAY" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" "CEPH OSD" +echo "------------------------------------------------------------------------------------------------------------------------------------" -# SATA/SAS drives -lsblk -d -o NAME | grep -v "nvme" | grep -v "rbd" | grep -v "loop" | grep -v "NAME" | while read device; do - if [ -b "/dev/$device" ]; then +# Build reverse map: device -> bay +declare -A DEVICE_TO_BAY +for bay in "${!DRIVE_MAP[@]}"; do + device="${DRIVE_MAP[$bay]}" + if [[ -n "$device" && "$device" != "EMPTY" ]]; then + DEVICE_TO_BAY[$device]=$bay + fi +done + +# Sort drives by bay position +for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); do + device="${DRIVE_MAP[$bay]}" + if [[ -n "$device" && "$device" != "EMPTY" && -b "/dev/$device" ]]; then size=$(lsblk -d -n -o SIZE "/dev/$device" 2>/dev/null) smart_info=$(get_drive_smart_info "$device") IFS='|' read -r type temp health model serial <<< "$smart_info" - printf "%-15s %-10s %-8s %-8s %-8s %-30s %-20s\n" "/dev/$device" "$size" "$type" "$temp" "$health" "$model" "$serial" + + # Check for Ceph OSD + osd_id=$(ceph-volume lvm list 2>/dev/null | grep -B 20 "/dev/$device" | grep "osd id" | awk '{print "osd."$3}' | head -1) + [[ -z "$osd_id" ]] && osd_id="-" + + printf "%-5s %-15s %-10s %-8s %-8s %-8s %-30s %-20s %-10s\n" "$bay" "/dev/$device" "$size" "$type" "$temp" "$health" "$model" "$serial" "$osd_id" fi done