diff --git a/driveAtlas.sh b/driveAtlas.sh index a7a7b69..5f75012 100644 --- a/driveAtlas.sh +++ b/driveAtlas.sh @@ -855,12 +855,32 @@ done # Sort drives by bay position (numeric bays first, then m2 slots) # Combine numeric bays (sorted numerically) with m2 slots (sorted alphanumerically) all_bays=$(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n; printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^m2-' | sort) + +# Parallel SMART data collection for faster execution +# Collect SMART data in background jobs, store in temp files +if [[ "$SKIP_SMART" != true ]]; then + SMART_CACHE_DIR="$(mktemp -d)" + log_info "Collecting SMART data in parallel..." + + for bay in $all_bays; do + device="${DRIVE_MAP[$bay]}" + if [[ -n "$device" && "$device" != "EMPTY" && -b "/dev/$device" ]]; then + # Launch background job for each device + (get_drive_smart_info "$device" > "$SMART_CACHE_DIR/$device") & + fi + done + + # Wait for all background SMART queries to complete + wait + log_info "SMART data collection complete" +fi + for bay in $all_bays; do device="${DRIVE_MAP[$bay]}" if [[ -n "$device" && "$device" != "EMPTY" && -b "/dev/$device" ]]; then size="$(lsblk -d -n -o SIZE "/dev/$device" 2>/dev/null)" - # Get SMART info (or defaults if skipped) + # Get SMART info from cache (or defaults if skipped) if [[ "$SKIP_SMART" == true ]]; then type="-" temp="-" @@ -869,7 +889,12 @@ for bay in $all_bays; do serial="-" warnings="" else - smart_info="$(get_drive_smart_info "$device")" + # Read from cached SMART data + if [[ -f "$SMART_CACHE_DIR/$device" ]]; then + smart_info="$(cat "$SMART_CACHE_DIR/$device")" + else + smart_info="" + fi IFS='|' read -r type temp health model serial warnings <<< "$smart_info" fi @@ -926,6 +951,11 @@ for bay in $all_bays; do fi done +# Clean up SMART cache directory +if [[ -n "${SMART_CACHE_DIR:-}" && -d "$SMART_CACHE_DIR" ]]; then + rm -rf "$SMART_CACHE_DIR" +fi + # NVMe drives (only show unmapped ones - mapped NVMe drives appear in main table) nvme_devices=$(lsblk -d -n -o NAME,SIZE | grep "^nvme" 2>/dev/null) if [[ -n "$nvme_devices" ]]; then