Add bay-sorted drive table and Ceph OSD tracking

Major enhancements:
- Drive details now sorted by physical bay position (1-10) instead of alphabetically
- Added BAY column to show physical location
- Added CEPH OSD column to show which OSD each drive hosts
- Fixed ASCII art right border alignment (final fix)
- Drives now display in logical order matching physical layout

This makes it much easier to correlate physical drives with their Ceph OSDs
and understand the layout at a glance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-06 16:25:56 -05:00
parent fd587eca64
commit 5430a9242f

View File

@@ -36,21 +36,21 @@ generate_10bay_layout() {
for bay in {1..10}; do for bay in {1..10}; do
printf "┌──────────┐ " printf "┌──────────┐ "
done done
printf " │\n" printf " │\n"
# Bay contents # Bay contents
printf "│ " printf "│ "
for bay in {1..10}; do for bay in {1..10}; do
printf "│%-2d:%-7s│ " "$bay" "${DRIVE_MAP[$bay]:-EMPTY}" printf "│%-2d:%-7s│ " "$bay" "${DRIVE_MAP[$bay]:-EMPTY}"
done done
printf " │\n" printf " │\n"
# Bay bottom borders # Bay bottom borders
printf "│ " printf "│ "
for bay in {1..10}; do for bay in {1..10}; do
printf "└──────────┘ " printf "└──────────┘ "
done done
printf " │\n" printf " │\n"
printf "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n" printf "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n"
} }
@@ -211,17 +211,32 @@ esac
# Drive Details Section # Drive Details Section
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
echo -e "\n=== Drive Details with SMART Status ===" echo -e "\n=== Drive Details with SMART Status (by Bay Position) ==="
printf "%-15s %-10s %-8s %-8s %-8s %-30s %-20s\n" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" printf "%-5s %-15s %-10s %-8s %-8s %-8s %-30s %-20s %-10s\n" "BAY" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" "CEPH OSD"
echo "----------------------------------------------------------------------------------------------------------------------------" echo "------------------------------------------------------------------------------------------------------------------------------------"
# SATA/SAS drives # Build reverse map: device -> bay
lsblk -d -o NAME | grep -v "nvme" | grep -v "rbd" | grep -v "loop" | grep -v "NAME" | while read device; do declare -A DEVICE_TO_BAY
if [ -b "/dev/$device" ]; then 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) size=$(lsblk -d -n -o SIZE "/dev/$device" 2>/dev/null)
smart_info=$(get_drive_smart_info "$device") smart_info=$(get_drive_smart_info "$device")
IFS='|' read -r type temp health model serial <<< "$smart_info" 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 fi
done done