Compare commits

..

2 Commits

Author SHA1 Message Date
cschantz 17fa38f349 Fix find_fpm_pool_config to work properly on cPanel
- Update find_fpm_pool_config in php-action-executor.sh
- Add proper domain matching for cPool configs
- cPanel names pool configs after the domain, not the username
- Add wildcard matching as fallback
- Function now successfully locates pool config files
- Critical fix for single-domain optimization in Option 4

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-18 17:30:32 -05:00
cschantz 7a44ff81d4 Fix broken traffic analysis functions in php-scanner.sh
- Fix find_domain_owner: Remove leading whitespace from username
- Fix find_domain_access_log: Follow symlinks with -L flag
- Add fallback paths for Apache domlogs directory
- Add fallback to public_html if access-logs not found
- Now properly detects peak concurrent requests
- Traffic filtering and batch analyzer prioritization now functional

Issues fixed:
- find_domain_owner returned ' pickledperil' instead of 'pickledperil'
- find command didn't follow symlinks in /home/user/access-logs
- Access logs are typically in /etc/apache2/logs/domlogs

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-18 17:27:58 -05:00
2 changed files with 37 additions and 10 deletions
+18 -5
View File
@@ -514,13 +514,26 @@ find_fpm_pool_config() {
local username="$1" local username="$1"
local domain="$2" local domain="$2"
# Try using existing function if available local pool_config=""
if type find_fpm_pool_config_internal >/dev/null 2>&1; then
find_fpm_pool_config_internal "$username" "$domain" # Try cPanel paths first (most common)
return $? # cPanel typically names pools after the domain
if [ -n "$domain" ]; then
pool_config=$(find /opt/cpanel/ea-php*/root/etc/php-fpm.d/ -name "$domain.conf" 2>/dev/null | head -1)
[ -n "$pool_config" ] && { echo "$pool_config"; return 0; }
fi fi
# Fallback: search common locations # Try username
pool_config=$(find /opt/cpanel/ea-php*/root/etc/php-fpm.d/ -name "$username.conf" 2>/dev/null | head -1)
[ -n "$pool_config" ] && { echo "$pool_config"; return 0; }
# Try matching any domain under this user
if [ -n "$domain" ]; then
pool_config=$(find /opt/cpanel/ea-php*/root/etc/php-fpm.d/ -name "*$domain*" 2>/dev/null | head -1)
[ -n "$pool_config" ] && { echo "$pool_config"; return 0; }
fi
# Try Debian/Ubuntu paths
local common_paths=( local common_paths=(
"/etc/php-fpm.d/${username}.conf" "/etc/php-fpm.d/${username}.conf"
"/etc/php/7.4/fpm/pool.d/${username}.conf" "/etc/php/7.4/fpm/pool.d/${username}.conf"
+19 -5
View File
@@ -454,7 +454,7 @@ find_domain_owner() {
case "${SYS_CONTROL_PANEL:-unknown}" in case "${SYS_CONTROL_PANEL:-unknown}" in
cpanel) cpanel)
grep "^${domain}:" /etc/trueuserdomains 2>/dev/null | cut -d: -f2 grep "^${domain}:" /etc/trueuserdomains 2>/dev/null | cut -d: -f2 | tr -d ' '
;; ;;
plesk) plesk)
if command_exists mysql && [ -f /etc/psa/.psa.shadow ]; then if command_exists mysql && [ -f /etc/psa/.psa.shadow ]; then
@@ -482,17 +482,31 @@ find_domain_access_log() {
local owner local owner
owner=$(find_domain_owner "$domain") owner=$(find_domain_owner "$domain")
if [ -n "$owner" ]; then if [ -n "$owner" ]; then
find "/home/${owner}/public_html" -maxdepth 2 -name "access_log*" -type f 2>/dev/null | head -1 # Try access-logs directory first (follows symlinks)
local log_file
log_file=$(find -L "/home/${owner}/access-logs" -type f -name "*${domain}*" 2>/dev/null | head -1)
# If not found, try Apache domlogs directory directly
if [ -z "$log_file" ] && [ -d "/etc/apache2/logs/domlogs" ]; then
log_file=$(find "/etc/apache2/logs/domlogs" -type f -name "*${domain}*" 2>/dev/null | head -1)
fi
# If not found, try public_html
if [ -z "$log_file" ] && [ -d "/home/${owner}/public_html" ]; then
log_file=$(find "/home/${owner}/public_html" -maxdepth 2 -type f -name "access_log*" 2>/dev/null | head -1)
fi
echo "$log_file"
fi fi
;; ;;
plesk) plesk)
find "/var/www/vhosts/${domain}/statistics/logs" -name "access_log*" -type f 2>/dev/null | head -1 find "/var/www/vhosts/${domain}/statistics/logs" -type f -name "access_log*" 2>/dev/null | head -1
;; ;;
interworx) interworx)
find "/home/*/public_html/${domain}" -name "access_log*" -type f 2>/dev/null | head -1 find "/home/*/public_html/${domain}" -type f -name "access_log*" 2>/dev/null | head -1
;; ;;
*) *)
find /var/log -name "*${domain}*access*log*" -type f 2>/dev/null | head -1 find /var/log -type f -name "*${domain}*access*log*" 2>/dev/null | head -1
;; ;;
esac esac
} }