From 1dd950b358394d31f4956fd99dde64a7b4950209 Mon Sep 17 00:00:00 2001 From: cschantz Date: Mon, 3 Nov 2025 21:17:45 -0500 Subject: [PATCH] Fix: Scan logs in subdirectories to catch all domain errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: Was missing 500 errors from logs stored in subdirectories like /var/log/apache2/domlogs/username/domain.com Changed from simple glob (domlogs/*) to recursive find command that: - Scans all files in domlogs directory AND subdirectories - Excludes system files (bytes_log, offset, error_log, ftpxferlog, ssl_log) - Finds ALL domain access logs regardless of location This ensures we catch errors like "GET /ay.php HTTP/1.1" 500 that were previously missed in subdirectory logs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/website/500-error-tracker.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/website/500-error-tracker.sh b/modules/website/500-error-tracker.sh index e2dba34..8eb69cc 100755 --- a/modules/website/500-error-tracker.sh +++ b/modules/website/500-error-tracker.sh @@ -59,21 +59,22 @@ declare -A domain_user total_500s=0 filtered_bots=0 -# Scan all domain access logs for 500 errors -for log in "$DOMLOGS_DIR"/*; do +# Scan all domain access logs for 500 errors (including subdirectories) +while IFS= read -r log; do [ -f "$log" ] || continue [[ "$log" =~ (bytes_log|offset|error_log|ftpxferlog|-ssl_log)$ ]] && continue + # Extract domain from log filename domain="${log##*/}" domain="${domain%%-*}" # Skip non-domain system logs (proxy, localhost, etc.) [[ "$domain" =~ ^(proxy|localhost|default|cpanel|webmail|whm|cpcalendars|cpcontacts|webdisk)$ ]] && continue - + # Find cPanel user for this domain user=$(grep -l "DNS.*$domain" /var/cpanel/users/* 2>/dev/null | head -1 | xargs basename 2>/dev/null) [ -z "$user" ] && user="unknown" - + domain_user["$domain"]="$user" # Scan for 500 errors in this log @@ -130,7 +131,7 @@ for log in "$DOMLOGS_DIR"/*; do echo "$domain|$user|$status|$url|$timestamp|$ip" >> "$ERRORS_500" fi done < <(tail -n 100000 "$log" 2>/dev/null) -done +done < <(find "$DOMLOGS_DIR" -type f ! -name "*bytes_log" ! -name "*offset*" ! -name "*error_log" ! -name "*ftpxferlog*" ! -name "*-ssl_log" 2>/dev/null) if [ "$total_500s" -eq 0 ]; then echo ""