diff --git a/modules/performance/php-fpm-batch-analyzer.sh b/modules/performance/php-fpm-batch-analyzer.sh index 0a57eff..4b6c32b 100755 --- a/modules/performance/php-fpm-batch-analyzer.sh +++ b/modules/performance/php-fpm-batch-analyzer.sh @@ -91,6 +91,19 @@ cecho "${CYAN}────────────────────── # Get all users and domains users=$(list_all_users) +# CRITICAL FIX: Build list of ALL domains on server FIRST +# This is needed for accurate traffic percentage calculation +declare -a all_server_domains +local all_domains_string="" +while IFS= read -r username; do + [ -z "$username" ] && continue + user_domains=$(get_user_domains "$username") + while IFS= read -r domain; do + [ -z "$domain" ] && continue + all_domains_string="$all_domains_string$domain"$'\n' + done <<< "$user_domains" +done <<< "$users" + # Initialize tracking arrays declare -a domain_list declare -a domain_owner @@ -157,7 +170,8 @@ while IFS= read -r username; do # Calculate recommended using THREE-CONSTRAINT INTELLIGENT ALGORITHM # Get traffic percentage for this domain - traffic_percentage=$(get_domain_traffic_percentage "$username" "$domain" "$user_domains" 2>/dev/null | cut -d'|' -f1) + # CRITICAL FIX: Pass ALL server domains, not just user's domains! + traffic_percentage=$(get_domain_traffic_percentage "$username" "$domain" "$all_domains_string" 2>/dev/null | cut -d'|' -f1) traffic_percentage=${traffic_percentage:-50} # Use intelligent three-constraint model: MIN(memory, traffic, fair_share)