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

@@ -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