Improve error display with grouping and counting
- Group identical errors and show occurrence count - Color-code by frequency (HIGH/MEDIUM/LOW) - Show top 20 most frequent errors instead of all - Clean up ModSecurity noise (unique_id, pid, tid tags) - Skip empty error messages - Exclude FTP logs and bytes_log files from analysis - Much cleaner output focused on actionable errors - Answer: Access logs show 5xx errors (500-599), not 404s
This commit is contained in:
@@ -159,7 +159,7 @@ if [ -d "$DOMLOGS_DIR" ]; then
|
|||||||
else
|
else
|
||||||
# All domains
|
# All domains
|
||||||
for log in "$DOMLOGS_DIR"/*; do
|
for log in "$DOMLOGS_DIR"/*; do
|
||||||
[ -f "$log" ] && ! [[ "$log" =~ (bytes_log|offset|error_log)$ ]] && \
|
[ -f "$log" ] && ! [[ "$log" =~ (bytes_log|offset|error_log|ftpxferlog)$ ]] && \
|
||||||
echo "$log|domlog_$(basename "$log")" >> "$LOG_FILES_LIST"
|
echo "$log|domlog_$(basename "$log")" >> "$LOG_FILES_LIST"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@@ -295,8 +295,20 @@ extract_useful_info() {
|
|||||||
# Extract file path if PHP error
|
# Extract file path if PHP error
|
||||||
file_path=$(echo "$line" | grep -oE "in /[^ ]+\.php" | sed 's/in //' || echo "")
|
file_path=$(echo "$line" | grep -oE "in /[^ ]+\.php" | sed 's/in //' || echo "")
|
||||||
|
|
||||||
# Extract error message (simplified)
|
# Extract error message (clean up ModSec noise, timestamps, etc.)
|
||||||
error_msg=$(echo "$line" | sed 's/^\[.*\] //' | sed 's/\[client [^]]*\] //' | cut -c1-100)
|
error_msg=$(echo "$line" | \
|
||||||
|
sed 's/^\[.*\] //' | \
|
||||||
|
sed 's/\[client [^]]*\] //' | \
|
||||||
|
sed 's/\[unique_id "[^"]*"\]//g' | \
|
||||||
|
sed 's/\[pid [^]]*\]//g' | \
|
||||||
|
sed 's/\[tid [^]]*\]//g' | \
|
||||||
|
grep -v "^$" | \
|
||||||
|
cut -c1-150)
|
||||||
|
|
||||||
|
# Skip if error message is empty or just whitespace
|
||||||
|
if [ -z "$(echo "$error_msg" | tr -d '[:space:]')" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$domain|$file_path|$error_msg"
|
echo "$domain|$file_path|$error_msg"
|
||||||
}
|
}
|
||||||
@@ -444,31 +456,45 @@ done
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo " ERROR DETAILS"
|
echo " ERROR DETAILS (Top Issues)"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Show errors grouped by domain
|
# Group identical errors and count them
|
||||||
current_domain=""
|
awk -F'|' '{
|
||||||
domain_count=0
|
key = $1 "|" $3 # domain|error_msg (skip file_path for grouping)
|
||||||
|
file[$1"|"$3] = $2 # Store file path
|
||||||
|
count[key]++
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
for (key in count) {
|
||||||
|
split(key, parts, "|")
|
||||||
|
domain = parts[1]
|
||||||
|
error = parts[2]
|
||||||
|
file_path = file[key]
|
||||||
|
|
||||||
sort "$CRITICAL_ERRORS" | while IFS='|' read -r domain file_path error_msg; do
|
# Skip empty errors
|
||||||
if [ "$domain" != "$current_domain" ]; then
|
if (length(error) == 0) next
|
||||||
if [ -n "$current_domain" ]; then
|
|
||||||
echo ""
|
print count[key] "|" domain "|" file_path "|" error
|
||||||
fi
|
}
|
||||||
|
}' "$CRITICAL_ERRORS" | sort -t'|' -k1 -rn | head -20 | while IFS='|' read -r count domain file_path error_msg; do
|
||||||
((domain_count++))
|
|
||||||
[ $domain_count -gt 5 ] && break
|
# Color code by frequency
|
||||||
|
if [ "$count" -ge 10 ]; then
|
||||||
echo -e "${YELLOW}▼ $domain${NC}"
|
color="${RED}"
|
||||||
current_domain="$domain"
|
priority="[HIGH FREQUENCY]"
|
||||||
fi
|
elif [ "$count" -ge 5 ]; then
|
||||||
|
color="${YELLOW}"
|
||||||
if [ -n "$file_path" ]; then
|
priority="[MEDIUM]"
|
||||||
echo " File: $file_path"
|
else
|
||||||
|
color="${INFO_COLOR}"
|
||||||
|
priority=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "${color}● Occurred $count times${NC} $priority"
|
||||||
|
[ -n "$domain" ] && [ "$domain" != "unknown" ] && echo " Domain: $domain"
|
||||||
|
[ -n "$file_path" ] && echo " File: $file_path"
|
||||||
echo " Error: $error_msg"
|
echo " Error: $error_msg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user