Integrate batch analyzer into Option 2: Analyze All Domains
- Update analyze_all_domains() to call php-fpm-batch-analyzer.sh - Option 2 now shows domain-by-domain breakdown with current vs recommended max_children - Displays per-domain memory impact and total optimization potential - Provides full server-wide cumulative analysis instead of per-domain checks Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -191,105 +191,24 @@ analyze_all_domains() {
|
||||
show_banner
|
||||
cecho "${WHITE}${BOLD}SERVER-WIDE ANALYSIS${NC}"
|
||||
echo ""
|
||||
cecho "${YELLOW}This will analyze PHP configuration for ALL domains...${NC}"
|
||||
cecho "${YELLOW}This will show domain-by-domain PHP-FPM configuration analysis${NC}"
|
||||
cecho "${YELLOW}including memory impact and combined server load...${NC}"
|
||||
echo ""
|
||||
|
||||
if ! confirm "Continue?"; then
|
||||
return
|
||||
fi
|
||||
|
||||
show_banner
|
||||
cecho "${WHITE}${BOLD}Analyzing all domains...${NC}"
|
||||
echo ""
|
||||
# Call the dedicated batch analyzer script
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
local batch_analyzer="$script_dir/php-fpm-batch-analyzer.sh"
|
||||
|
||||
# Get all users
|
||||
local users
|
||||
users=$(list_all_users)
|
||||
|
||||
local total_domains=0
|
||||
local domains_with_issues=0
|
||||
|
||||
while IFS= read -r username; do
|
||||
local user_domains
|
||||
user_domains=$(get_user_domains "$username")
|
||||
|
||||
while IFS= read -r domain; do
|
||||
[ -z "$domain" ] && continue
|
||||
|
||||
total_domains=$((total_domains + 1))
|
||||
|
||||
cecho "${CYAN}[$total_domains] Analyzing: ${WHITE}$domain${NC}"
|
||||
|
||||
# Detect issues
|
||||
local issues
|
||||
issues=$(detect_php_config_issues "$username" "$domain")
|
||||
|
||||
# Count issues by severity
|
||||
local critical_count high_count medium_count low_count
|
||||
critical_count=$(echo "$issues" | grep -c "^[^|]*|CRITICAL|" || true)
|
||||
high_count=$(echo "$issues" | grep -c "^[^|]*|HIGH|" || true)
|
||||
medium_count=$(echo "$issues" | grep -c "^[^|]*|MEDIUM|" || true)
|
||||
low_count=$(echo "$issues" | grep -c "^[^|]*|LOW|" || true)
|
||||
|
||||
# Default to 0 if empty
|
||||
critical_count=${critical_count:-0}
|
||||
high_count=${high_count:-0}
|
||||
medium_count=${medium_count:-0}
|
||||
low_count=${low_count:-0}
|
||||
|
||||
local total_issues=$((critical_count + high_count + medium_count + low_count))
|
||||
|
||||
if [ "$total_issues" -gt 0 ]; then
|
||||
domains_with_issues=$((domains_with_issues + 1))
|
||||
|
||||
# Build issue summary
|
||||
local issue_summary=""
|
||||
[ "$critical_count" -gt 0 ] && issue_summary+="${RED}$critical_count CRITICAL${NC}, "
|
||||
[ "$high_count" -gt 0 ] && issue_summary+="${YELLOW}$high_count HIGH${NC}, "
|
||||
[ "$medium_count" -gt 0 ] && issue_summary+="$medium_count MEDIUM, "
|
||||
[ "$low_count" -gt 0 ] && issue_summary+="$low_count LOW, "
|
||||
issue_summary=${issue_summary%, } # Remove trailing comma
|
||||
|
||||
cecho " ${RED}✗${NC} Issues found: $issue_summary"
|
||||
|
||||
# Show critical/high issues
|
||||
while IFS='|' read -r issue_type severity message recommendation; do
|
||||
[ -z "$issue_type" ] && continue
|
||||
|
||||
if [[ "$severity" == "CRITICAL" ]] || [[ "$severity" == "HIGH" ]]; then
|
||||
cecho " ${RED}[$severity]${NC} $issue_type: $message"
|
||||
fi
|
||||
done <<< "$issues"
|
||||
|
||||
# Show what passed
|
||||
local checks_passed=""
|
||||
echo "$issues" | grep -q "max_children" || checks_passed+="max_children OK, "
|
||||
echo "$issues" | grep -q "memory_exhausted" || checks_passed+="memory OK, "
|
||||
echo "$issues" | grep -q "execution timeout" || checks_passed+="timeouts OK, "
|
||||
|
||||
if [ -n "$checks_passed" ]; then
|
||||
checks_passed=${checks_passed%, }
|
||||
cecho " ${GREEN}✓${NC} Checks passed: $checks_passed"
|
||||
fi
|
||||
if [ -f "$batch_analyzer" ]; then
|
||||
bash "$batch_analyzer"
|
||||
else
|
||||
cecho " ${GREEN}✓ All checks passed${NC} (max_children, memory, timeouts, config)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
done <<< "$user_domains"
|
||||
done <<< "$users"
|
||||
|
||||
# Summary
|
||||
cecho "${CYAN}═══════════════════════════════════════════════════════════════════${NC}"
|
||||
cecho "${WHITE}${BOLD}SUMMARY${NC}"
|
||||
cecho "${CYAN}═══════════════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
cecho " Total domains analyzed: ${WHITE}$total_domains${NC}"
|
||||
cecho " Domains with issues: ${RED}$domains_with_issues${NC}"
|
||||
cecho " Domains healthy: ${GREEN}$((total_domains - domains_with_issues))${NC}"
|
||||
echo ""
|
||||
cecho "${CYAN}═══════════════════════════════════════════════════════════════════${NC}"
|
||||
cecho "${RED}ERROR: Batch analyzer script not found at $batch_analyzer${NC}"
|
||||
read -p "Press Enter to continue..."
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user