diff --git a/driveAtlas.sh b/driveAtlas.sh index 60bfcef..ae2e585 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -14,63 +14,45 @@ generate_10bay_layout() { local hostname=$1 build_drive_map - # Calculate max width needed for drive names - max_width=0 - for bay in {1..10} "m2-1" "usb1" "usb2"; do - drive_text="${DRIVE_MAP[$bay]:-EMPTY}" - text_len=$((${#bay} + 1 + ${#drive_text})) - [[ $text_len -gt $max_width ]] && max_width=$text_len - done - - # Add padding for box borders - box_width=$((max_width + 4)) - - # Create box drawing elements - h_line=$(printf '%*s' "$box_width" '' | tr ' ' '─') - - # USB Section (if applicable) - if [[ -n "${DRIVE_MAP[usb1]}" || -n "${DRIVE_MAP[usb2]}" ]]; then - printf "\n External USB\n" - printf " ┌%s┐ ┌%s┐\n" "$h_line" "$h_line" - printf " │ %-${max_width}s │ │ %-${max_width}s │\n" "${DRIVE_MAP[usb1]:-EMPTY}" "${DRIVE_MAP[usb2]:-EMPTY}" - printf " └%s┘ └%s┘\n\n" "$h_line" "$h_line" - fi + # Fixed width for consistent box drawing (fits device names like "nvme0n1") + local drive_width=10 # Main chassis section - printf "┌──────────────────────────────────────────────────────────────┐\n" - printf "│ %-58s │\n" "$hostname" - printf "│ %-58s │\n" "10-Bay Hot-swap Chassis" - printf "│ │\n" + printf "┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n" + printf "│ %-126s │\n" "$hostname - 10-Bay Hot-swap Chassis" + printf "│ │\n" # M.2 NVMe slot if present if [[ -n "${DRIVE_MAP[m2-1]}" ]]; then - printf "│ M.2 NVMe Slot │\n" - printf "│ ┌%s┐ │\n" "$h_line" - printf "│ │ %-${max_width}s │ │\n" "${DRIVE_MAP[m2-1]:-EMPTY}" - printf "│ └%s┘ │\n" "$h_line" - printf "│ │\n" + printf "│ M.2 NVMe: %-10s │\n" "${DRIVE_MAP[m2-1]}" + printf "│ │\n" fi - printf "│ Front Hot-swap Bays │\n" + printf "│ Front Hot-swap Bays: │\n" + printf "│ │\n" - # Create bay rows - printf "│ " + # Bay top borders + printf "│ " for bay in {1..10}; do - printf "┌%s┐" "$h_line" + printf "┌──────────┐ " done - printf " │\n│ " + printf "│\n" + # Bay contents + printf "│ " for bay in {1..10}; do - printf "│%-2d:%-${max_width}s │" "$bay" "${DRIVE_MAP[$bay]:-EMPTY}" + printf "│%-2d:%-7s│ " "$bay" "${DRIVE_MAP[$bay]:-EMPTY}" done - printf " │\n│ " + printf "│\n" + # Bay bottom borders + printf "│ " for bay in {1..10}; do - printf "└%s┘" "$h_line" + printf "└──────────┘ " done - printf " │\n" + printf "│\n" - printf "└──────────────────────────────────────────────────────────────┘\n" + printf "└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n" } generate_large1_layout() { @@ -123,10 +105,10 @@ declare -A SERVER_MAPPINGS=( # - HBA bottom mini-SAS: bays 5,6,7,8 # - HBA top mini-SAS: bays 9,10 ["compute-storage-01"]=" - pci-0000:0d:00.0-ata-3 1 - pci-0000:0d:00.0-ata-4 2 - pci-0000:0d:00.0-ata-2 3 - pci-0000:0d:00.0-ata-1 4 + pci-0000:0d:00.0-ata-2 1 + pci-0000:0d:00.0-ata-1 2 + pci-0000:0d:00.0-ata-3 3 + pci-0000:0d:00.0-ata-4 4 pci-0000:01:00.0-sas-phy2-lun-0 5 pci-0000:01:00.0-sas-phy3-lun-0 6 pci-0000:01:00.0-sas-phy4-lun-0 7 diff --git a/get-serials.sh b/get-serials.sh new file mode 100644 index 0000000..760ee2c --- /dev/null +++ b/get-serials.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "=== Drive Serial Numbers ===" +for dev in sd{a..j}; do + if [ -b "/dev/$dev" ]; then + serial=$(sudo smartctl -i /dev/$dev 2>/dev/null | grep "Serial Number" | awk '{print $3}') + model=$(sudo smartctl -i /dev/$dev 2>/dev/null | grep "Device Model\|Model Number" | cut -d: -f2 | xargs) + size=$(lsblk -d -n -o SIZE /dev/$dev 2>/dev/null) + echo "/dev/$dev: $serial ($size - $model)" + fi +done