FIX: Access log location - check correct cPanel path first

cPanel standard access log location is /var/log/apache2/domlogs/
The old code was checking /etc/apache2/logs/domlogs first (wrong priority)

Changes:
- Check /var/log/apache2/domlogs FIRST (primary cPanel location)
- Then check /home/USER/access-logs (symlink, if user found)
- Then check /etc/apache2/logs/domlogs (alternative)
- Also improved Plesk (/var/www/vhosts/*/logs/) and InterWorx paths

This ensures peak concurrent values are calculated correctly when
logs exist. If logs don't exist for a domain, function now returns
empty string (can be handled with fallback).
This commit is contained in:
Developer
2026-04-20 19:08:27 -04:00
parent ba6848e113
commit c90f7155ce
+28 -15
View File
@@ -483,34 +483,47 @@ find_domain_access_log() {
case "${SYS_CONTROL_PANEL:-unknown}" in case "${SYS_CONTROL_PANEL:-unknown}" in
cpanel) cpanel)
# cPanel standard locations for access logs
# Primary: /var/log/apache2/domlogs/DOMAIN (or DOMAIN-error_log, etc)
# Secondary: /home/USER/access-logs/ (symlink to above)
local log_file
# Try standard cPanel domlogs directory FIRST (primary location)
log_file=$(find "/var/log/apache2/domlogs" -maxdepth 1 -type f -name "*${domain}*" 2>/dev/null | head -1)
# If not found, try user's access-logs directory (symlink, follows)
if [ -z "$log_file" ]; then
local owner local owner
owner=$(find_domain_owner "$domain") owner=$(find_domain_owner "$domain")
if [ -n "$owner" ]; then if [ -n "$owner" ] && [ -d "/home/${owner}/access-logs" ]; then
# Try access-logs directory first (follows symlinks) log_file=$(find -L "/home/${owner}/access-logs" -maxdepth 1 -type f -name "*${domain}*" 2>/dev/null | head -1)
local log_file fi
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 fi
# If not found, try public_html # Try alternative cPanel path
if [ -z "$log_file" ] && [ -d "/home/${owner}/public_html" ]; then if [ -z "$log_file" ] && [ -d "/etc/apache2/logs/domlogs" ]; then
log_file=$(find "/home/${owner}/public_html" -maxdepth 2 -type f -name "access_log*" 2>/dev/null | head -1) log_file=$(find "/etc/apache2/logs/domlogs" -maxdepth 1 -type f -name "*${domain}*" 2>/dev/null | head -1)
fi fi
echo "$log_file" echo "$log_file"
fi
;; ;;
plesk) plesk)
find "/var/www/vhosts/${domain}/statistics/logs" -type f -name "access_log*" 2>/dev/null | head -1 # Plesk standard locations
# Format varies: /var/www/vhosts/DOMAIN/logs/ or /var/www/vhosts/system/DOMAIN/logs/
find "/var/www/vhosts" -path "*/logs/*" -name "*access*" -o -path "*/system/${domain}/logs/*" 2>/dev/null | head -1
;; ;;
interworx) interworx)
find "/home/*/public_html/${domain}" -type f -name "access_log*" 2>/dev/null | head -1 # InterWorx standard location: /home/USER/var/DOMAIN/logs/
find "/home/*/var/${domain}/logs" -type f -name "*access*" 2>/dev/null | head -1
;; ;;
*) *)
find /var/log -type f -name "*${domain}*access*log*" 2>/dev/null | head -1 # Standalone/unknown - search common locations
local log_file
log_file=$(find "/var/log/apache2/domlogs" -maxdepth 1 -type f -name "*${domain}*" 2>/dev/null | head -1)
if [ -z "$log_file" ]; then
log_file=$(find "/var/log" -maxdepth 2 -type f -name "*${domain}*access*" 2>/dev/null | head -1)
fi
echo "$log_file"
;; ;;
esac esac
} }