Compare commits

...

3 Commits

Author SHA1 Message Date
e6cc9a3853 Fix Rotation Rate regex to handle leading whitespace
The smartctl output has leading whitespace before field names:
  "Rotation Rate:    7200 rpm"

Removed the ^ anchor from the regex so it matches lines with
leading whitespace. This fixes HDD detection for drives that
have proper Rotation Rate fields in their SMART data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:07:35 -05:00
51cc739da5 Add debug logging for Ceph OSD detection
Added log_info messages to show:
- Count of OSDs found
- Each device-to-OSD mapping as discovered

Also fixed array subscript quoting in CEPH_DEVICE_TO_OSD.

Run with --verbose to see Ceph detection diagnostics.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:04:49 -05:00
2b9871d887 Fix HDD/SSD detection to be more accurate
Improved device type detection:
- Use anchored regex (^Rotation Rate:) to avoid false matches
- Check for actual RPM values (e.g., "7200 rpm") to confirm HDD
- Only match SSD in model name field, not anywhere in output
- Default to HDD when Rotation Rate field is missing

This fixes drives like WDC WD80EFZZ being incorrectly detected
as SSDs when the Rotation Rate field wasn't being matched.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 20:02:25 -05:00

View File

@@ -665,6 +665,7 @@ build_ceph_cache() {
# Parse ceph-volume lvm list output # Parse ceph-volume lvm list output
# Format: blocks starting with "====== osd.X =======" followed by device info # Format: blocks starting with "====== osd.X =======" followed by device info
local current_osd="" local current_osd=""
local osd_count=0
while IFS= read -r line; do while IFS= read -r line; do
# Match OSD header: "====== osd.5 =======" # Match OSD header: "====== osd.5 ======="
if [[ "$line" =~ ======[[:space:]]+osd\.([0-9]+)[[:space:]]+======= ]]; then if [[ "$line" =~ ======[[:space:]]+osd\.([0-9]+)[[:space:]]+======= ]]; then
@@ -672,9 +673,12 @@ build_ceph_cache() {
# Match block device line: " block device /dev/sda" # Match block device line: " block device /dev/sda"
elif [[ -n "$current_osd" && "$line" =~ block[[:space:]]device[[:space:]]+/dev/([^[:space:]]+) ]]; then elif [[ -n "$current_osd" && "$line" =~ block[[:space:]]device[[:space:]]+/dev/([^[:space:]]+) ]]; then
local dev_name="${BASH_REMATCH[1]}" local dev_name="${BASH_REMATCH[1]}"
CEPH_DEVICE_TO_OSD[$dev_name]="$current_osd" CEPH_DEVICE_TO_OSD["$dev_name"]="$current_osd"
((osd_count++))
log_info "Found $current_osd on $dev_name"
fi fi
done < <(ceph-volume lvm list 2>/dev/null) done < <(ceph-volume lvm list 2>/dev/null)
log_info "Cached $osd_count Ceph OSDs"
# Skip if ceph command is not available # Skip if ceph command is not available
if ! command -v ceph &>/dev/null; then if ! command -v ceph &>/dev/null; then
@@ -751,16 +755,28 @@ parse_smart_data() {
fi fi
# Device type detection - handles SSD, HDD, and NVMe # Device type detection - handles SSD, HDD, and NVMe
# Priority: 1) NVMe by name, 2) Rotation Rate field, 3) Model name hints, 4) Default HDD
if [[ "$device" == nvme* ]]; then if [[ "$device" == nvme* ]]; then
type="NVMe" type="NVMe"
elif echo "$smart_info" | grep -q "Rotation Rate"; then elif echo "$smart_info" | grep -qE "Rotation Rate:"; then
if echo "$smart_info" | grep "Rotation Rate" | grep -qiE "solid state|0 rpm"; then # Check the Rotation Rate field value (may have leading whitespace)
local rotation_rate
rotation_rate="$(echo "$smart_info" | grep -E "Rotation Rate:" | head -1)"
if echo "$rotation_rate" | grep -qiE "solid state"; then
type="SSD" type="SSD"
elif echo "$rotation_rate" | grep -qE "[0-9]+ rpm"; then
# Has actual RPM value (e.g., "7200 rpm") - it's an HDD
type="HDD"
else else
# Unknown rotation rate, default to HDD
type="HDD" type="HDD"
fi fi
elif echo "$smart_info" | grep -qiE "SSD|Solid State"; then elif echo "$smart_info" | grep -qE "Device Model:.*SSD|Model Number:.*SSD"; then
# Match SSD in the model name field
type="SSD" type="SSD"
else
# Default to HDD for spinning rust
type="HDD"
fi fi
# Health status (basic SMART check) # Health status (basic SMART check)