Fix: Scan logs in subdirectories to catch all domain errors
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 ""
|
||||
|
||||
Reference in New Issue
Block a user