Fix Ceph OSD status parsing to correctly read up/down and in/out
Fixed parsing of ceph osd tree output: - Column 5 is STATUS (up/down) not column 6 - Column 6 is REWEIGHT (1.0 = in, 0 = out) - Now correctly shows up/in for active OSDs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -240,10 +240,22 @@ for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); d
|
|||||||
if [[ -n "$osd_id" ]]; then
|
if [[ -n "$osd_id" ]]; then
|
||||||
# Get in/out and up/down status from ceph osd tree
|
# Get in/out and up/down status from ceph osd tree
|
||||||
osd_num=$(echo "$osd_id" | sed 's/osd\.//')
|
osd_num=$(echo "$osd_id" | sed 's/osd\.//')
|
||||||
in_status=$(ceph osd tree 2>/dev/null | grep "osd.$osd_num " | awk '{print $5}')
|
# Parse ceph osd tree output - column 5 is STATUS (up/down), column 6 is REWEIGHT (1.0 = in, 0 = out)
|
||||||
up_status=$(ceph osd tree 2>/dev/null | grep "osd.$osd_num " | awk '{print $6}')
|
tree_line=$(ceph osd tree 2>/dev/null | grep -E "^\s*${osd_num}\s+" | grep "osd.${osd_num}")
|
||||||
[[ "$up_status" == "1" ]] && up_status="up" || up_status="down"
|
up_status=$(echo "$tree_line" | awk '{print $5}')
|
||||||
[[ "$in_status" == "1" ]] && in_status="in" || in_status="out"
|
reweight=$(echo "$tree_line" | awk '{print $6}')
|
||||||
|
|
||||||
|
# Default to unknown if we can't parse
|
||||||
|
[[ -z "$up_status" ]] && up_status="unknown"
|
||||||
|
[[ -z "$reweight" ]] && reweight="0"
|
||||||
|
|
||||||
|
# Determine in/out based on reweight (1.0 = in, 0 = out)
|
||||||
|
if (( $(echo "$reweight > 0" | bc -l 2>/dev/null || echo 0) )); then
|
||||||
|
in_status="in"
|
||||||
|
else
|
||||||
|
in_status="out"
|
||||||
|
fi
|
||||||
|
|
||||||
ceph_status="${up_status}/${in_status}"
|
ceph_status="${up_status}/${in_status}"
|
||||||
else
|
else
|
||||||
osd_id="-"
|
osd_id="-"
|
||||||
|
|||||||
Reference in New Issue
Block a user