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.
This commit is contained in:
@@ -59,11 +59,12 @@ declare -A domain_user
|
|||||||
total_500s=0
|
total_500s=0
|
||||||
filtered_bots=0
|
filtered_bots=0
|
||||||
|
|
||||||
# Scan all domain access logs for 500 errors
|
# Scan all domain access logs for 500 errors (including subdirectories)
|
||||||
for log in "$DOMLOGS_DIR"/*; do
|
while IFS= read -r log; do
|
||||||
[ -f "$log" ] || continue
|
[ -f "$log" ] || continue
|
||||||
[[ "$log" =~ (bytes_log|offset|error_log|ftpxferlog|-ssl_log)$ ]] && continue
|
[[ "$log" =~ (bytes_log|offset|error_log|ftpxferlog|-ssl_log)$ ]] && continue
|
||||||
|
|
||||||
|
# Extract domain from log filename
|
||||||
domain="${log##*/}"
|
domain="${log##*/}"
|
||||||
domain="${domain%%-*}"
|
domain="${domain%%-*}"
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ for log in "$DOMLOGS_DIR"/*; do
|
|||||||
echo "$domain|$user|$status|$url|$timestamp|$ip" >> "$ERRORS_500"
|
echo "$domain|$user|$status|$url|$timestamp|$ip" >> "$ERRORS_500"
|
||||||
fi
|
fi
|
||||||
done < <(tail -n 100000 "$log" 2>/dev/null)
|
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
|
if [ "$total_500s" -eq 0 ]; then
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user