diff --git a/driveAtlas.sh b/driveAtlas.sh index 80389ea..6ef0796 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -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