Add Ceph OSD status and boot drive detection

New features:
- Added STATUS column showing Ceph OSD up/down and in/out status
  Format: "up/in", "up/out", "down/in", etc.
- Added USAGE column to identify boot drives and mount points
  Shows "BOOT" for root filesystem, mount point for others, "-" for OSDs
- Improved table layout with all relevant drive information

Now you can see at a glance:
- Which drives are boot drives
- Which OSDs are up and in the cluster
- Any problematic OSDs that are down or out

🤖 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:28:44 -05:00
parent 5430a9242f
commit 1800b59a25

View File

@@ -212,8 +212,8 @@ esac
#------------------------------------------------------------------------------
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 "------------------------------------------------------------------------------------------------------------------------------------"
printf "%-5s %-15s %-10s %-8s %-8s %-8s %-30s %-20s %-12s %-10s %-10s\n" "BAY" "DEVICE" "SIZE" "TYPE" "TEMP" "HEALTH" "MODEL" "SERIAL" "CEPH OSD" "STATUS" "USAGE"
echo "----------------------------------------------------------------------------------------------------------------------------------------------------"
# Build reverse map: device -> bay
declare -A DEVICE_TO_BAY
@@ -234,9 +234,33 @@ for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); d
# 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"
# Get Ceph status if OSD exists
ceph_status="-"
if [[ -n "$osd_id" ]]; then
# Get in/out and up/down status from ceph osd tree
osd_num=$(echo "$osd_id" | sed 's/osd\.//')
in_status=$(ceph osd tree 2>/dev/null | grep "osd.$osd_num " | awk '{print $5}')
up_status=$(ceph osd tree 2>/dev/null | grep "osd.$osd_num " | awk '{print $6}')
[[ "$up_status" == "1" ]] && up_status="up" || up_status="down"
[[ "$in_status" == "1" ]] && in_status="in" || in_status="out"
ceph_status="${up_status}/${in_status}"
else
osd_id="-"
fi
# Check if boot drive
usage="-"
if mount | grep -q "^/dev/${device}"; then
mount_point=$(mount | grep "^/dev/${device}" | awk '{print $3}' | head -1)
if [[ "$mount_point" == "/" ]]; then
usage="BOOT"
else
usage="$mount_point"
fi
fi
printf "%-5s %-15s %-10s %-8s %-8s %-8s %-30s %-20s %-12s %-10s %-10s\n" "$bay" "/dev/$device" "$size" "$type" "$temp" "$health" "$model" "$serial" "$osd_id" "$ceph_status" "$usage"
fi
done