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>
This commit is contained in:
cschantz
2026-02-18 17:27:58 -05:00
parent 2dd5ba0422
commit 7a44ff81d4
+19 -5
View File
@@ -454,7 +454,7 @@ find_domain_owner() {
case "${SYS_CONTROL_PANEL:-unknown}" in
cpanel)
grep "^${domain}:" /etc/trueuserdomains 2>/dev/null | cut -d: -f2
grep "^${domain}:" /etc/trueuserdomains 2>/dev/null | cut -d: -f2 | tr -d ' '
;;
plesk)
if command_exists mysql && [ -f /etc/psa/.psa.shadow ]; then
@@ -482,17 +482,31 @@ find_domain_access_log() {
local owner
owner=$(find_domain_owner "$domain")
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
;;
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)
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
}