From 5430a9242fd76413296bd802e917513d70c8ad4d Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 6 Jan 2026 16:25:56 -0500 Subject: [PATCH] Add bay-sorted drive table and Ceph OSD tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- driveAtlas.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) 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