Compare commits

..

3 Commits

Author SHA1 Message Date
cschantz db093d7b9b Add progress indicator to bot analyzer log parsing
The bot analyzer was silently processing thousands of log files with no progress feedback, appearing to stall on large servers.

Changes:
• Added progress counter showing every 50 log files parsed
• Displays current domain being processed
• Shows format: "Parsed 150 log files... (current: domain.com)"
• Clears progress line when complete to avoid clutter
• Interval set to 50 files (adjustable via progress_interval variable)

Example output:
  Parsing logs from: /var/log/apache2/domlogs
  Parsed 50 log files... (current: example.com)
  Parsed 100 log files... (current: another.com)
  Logs parsed successfully (125432 entries)

This gives real-time feedback on servers with 1000+ log files without overwhelming the output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 20:55:33 -05:00
cschantz 79978c7d43 Update REFDB_FORMAT.txt with domain lookup fix documentation
Updated WordPress Cron Manager section with:
• Two-step domain lookup method (main_domain → servername fallback)
• Correct wp-config.php placement (before stop editing comment)
• Added commit 172a115 to recent commits section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 20:41:57 -05:00
cschantz 172a115175 Fix domain lookup in WordPress Cron Manager
The domain lookup was failing because it only searched for 'servername:' in /var/cpanel/userdata/*/main files, but cPanel stores domain information differently:

- main files use 'main_domain: domain.com' (YAML format)
- domain-specific files use 'servername: domain.com' (YAML format)

Changes:
• Added two-step domain lookup process
• Method 1: Check main_domain in /var/cpanel/userdata/*/main files
• Method 2: Fallback to search all domain files for servername
• Skip cache files (.cache, cache, cache.json) during search
• Applied fix to all three domain lookup locations (options 2, 5, 6)

This fixes the "WordPress installation not found for domain" error that occurred when domains weren't configured as main_domain.

Tested with pickledperil.com - lookup now works correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 20:41:13 -05:00
3 changed files with 103 additions and 5 deletions
+23 -2
View File
@@ -325,11 +325,19 @@ staggered_timing:
wp-config_modification: wp-config_modification:
function: disable_wpcron_in_config() function: disable_wpcron_in_config()
location: Line 2 after <?php tag location: Before "/* That's all, stop editing! */" comment (proper WordPress convention)
fallback: After <?php tag if "stop editing" not found
adds: define('DISABLE_WP_CRON', true); adds: define('DISABLE_WP_CRON', true);
safety: Backup created, verification, rollback on failure safety: Removes existing entries first, backup created, verification, rollback on failure
format: User crontabs (crontab -u $user) not system crontab format: User crontabs (crontab -u $user) not system crontab
domain_lookup_method:
# Fixed 2025-11-10 - Two-step lookup process
method_1: Check main_domain in /var/cpanel/userdata/*/main files (YAML: main_domain:)
method_2: Fallback to search domain-specific files for servername (YAML: servername:)
skip_files: "*.cache, */main, */cache, */cache.json"
rationale: cPanel stores main_domain in main files, servername in domain-specific files
cron_job_format: | cron_job_format: |
0,15,30,45 * * * * cd /home/user/public_html && /usr/bin/php -q wp-cron.php >/dev/null 2>&1 0,15,30,45 * * * * cd /home/user/public_html && /usr/bin/php -q wp-cron.php >/dev/null 2>&1
@@ -345,6 +353,19 @@ options:
0: Return to menu (cancel) 0: Return to menu (cancel)
[RECENT_COMMITS] [RECENT_COMMITS]
# Latest changes (2025-11-10)
commit: 172a115
date: 2025-11-10
title: Fix domain lookup in WordPress Cron Manager
files: modules/website/wordpress/wordpress-cron-manager.sh
changes:
- Fixed broken domain lookup (was only searching /var/cpanel/userdata/*/main for servername:)
- Added two-step lookup: main_domain in main files, then servername in domain files
- Applied fix to options 2, 5, 6 (all domain lookup locations)
- Skip cache files during search
testing: Verified with pickledperil.com - lookup now works correctly
# Latest changes (2025-11-07) # Latest changes (2025-11-07)
commit: 56776a1 commit: 56776a1
+12
View File
@@ -352,6 +352,9 @@ parse_logs() {
# Parse all domain logs (excluding -bytes_log, .offset, and error_log files) # Parse all domain logs (excluding -bytes_log, .offset, and error_log files)
# cPanel creates files like: domain.com, domain.com-ssl_log # cPanel creates files like: domain.com, domain.com-ssl_log
local file_count=0
local progress_interval=50
echo ""
find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | while read -r logfile; do find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | while read -r logfile; do
# Skip empty files # Skip empty files
[ -s "$logfile" ] || continue [ -s "$logfile" ] || continue
@@ -365,6 +368,12 @@ parse_logs() {
fi fi
fi fi
# Show progress every N files
file_count=$((file_count + 1))
if [ $((file_count % progress_interval)) -eq 0 ]; then
echo -ne "\r Parsed $file_count log files... (current: $domain)"
fi
# Parse Apache Combined Log Format with error handling # Parse Apache Combined Log Format with error handling
# Format: IP - - [timestamp] "METHOD URL PROTOCOL" STATUS SIZE "REFERRER" "USER-AGENT" # Format: IP - - [timestamp] "METHOD URL PROTOCOL" STATUS SIZE "REFERRER" "USER-AGENT"
awk -v domain="$domain" ' awk -v domain="$domain" '
@@ -411,6 +420,9 @@ parse_logs() {
}' "$logfile" >> "$TEMP_DIR/parsed_logs.txt" 2>/dev/null }' "$logfile" >> "$TEMP_DIR/parsed_logs.txt" 2>/dev/null
done done
# Clear the progress line
echo -ne "\r\033[K"
if [ ! -s "$TEMP_DIR/parsed_logs.txt" ]; then if [ ! -s "$TEMP_DIR/parsed_logs.txt" ]; then
print_alert "No log entries were parsed. Check log format or permissions." print_alert "No log entries were parsed. Check log format or permissions."
return 1 return 1
@@ -221,8 +221,30 @@ case "$choice" in
echo "Searching for WordPress installation for $domain..." echo "Searching for WordPress installation for $domain..."
# Try to find via cPanel user data # Try to find via cPanel user data
# Search both main_domain (in main files) and servername (in domain files)
wp_config="" wp_config=""
# Method 1: Check main_domain in /var/cpanel/userdata/*/main files
for userdata_file in /var/cpanel/userdata/*/main; do for userdata_file in /var/cpanel/userdata/*/main; do
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php"
if [ -f "$potential_config" ]; then
wp_config="$potential_config"
break
fi
fi
done
# Method 2: If not found, search all domain-specific files for servername
if [ -z "$wp_config" ]; then
for userdata_file in /var/cpanel/userdata/*/*; do
# Skip cache files and main files
[[ "$userdata_file" == *.cache ]] && continue
[[ "$userdata_file" == */main ]] && continue
[[ "$userdata_file" == */cache ]] && continue
[[ "$userdata_file" == */cache.json ]] && continue
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")") user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php" potential_config="/home/$user/public_html/wp-config.php"
@@ -232,6 +254,7 @@ case "$choice" in
fi fi
fi fi
done done
fi
if [ -z "$wp_config" ]; then if [ -z "$wp_config" ]; then
print_error "WordPress installation not found for $domain" print_error "WordPress installation not found for $domain"
@@ -463,7 +486,27 @@ case "$choice" in
# Find WordPress for domain # Find WordPress for domain
wp_config="" wp_config=""
# Method 1: Check main_domain in main files
for userdata_file in /var/cpanel/userdata/*/main; do for userdata_file in /var/cpanel/userdata/*/main; do
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php"
if [ -f "$potential_config" ]; then
wp_config="$potential_config"
break
fi
fi
done
# Method 2: Search domain-specific files for servername
if [ -z "$wp_config" ]; then
for userdata_file in /var/cpanel/userdata/*/*; do
[[ "$userdata_file" == *.cache ]] && continue
[[ "$userdata_file" == */main ]] && continue
[[ "$userdata_file" == */cache ]] && continue
[[ "$userdata_file" == */cache.json ]] && continue
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")") user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php" potential_config="/home/$user/public_html/wp-config.php"
@@ -473,6 +516,7 @@ case "$choice" in
fi fi
fi fi
done done
fi
if [ -z "$wp_config" ]; then if [ -z "$wp_config" ]; then
print_error "WordPress not found for $domain" print_error "WordPress not found for $domain"
@@ -573,7 +617,27 @@ case "$choice" in
# Find WordPress installation # Find WordPress installation
wp_config="" wp_config=""
# Method 1: Check main_domain in main files
for userdata_file in /var/cpanel/userdata/*/main; do for userdata_file in /var/cpanel/userdata/*/main; do
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php"
if [ -f "$potential_config" ]; then
wp_config="$potential_config"
break
fi
fi
done
# Method 2: Search domain-specific files for servername
if [ -z "$wp_config" ]; then
for userdata_file in /var/cpanel/userdata/*/*; do
[[ "$userdata_file" == *.cache ]] && continue
[[ "$userdata_file" == */main ]] && continue
[[ "$userdata_file" == */cache ]] && continue
[[ "$userdata_file" == */cache.json ]] && continue
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
user=$(basename "$(dirname "$userdata_file")") user=$(basename "$(dirname "$userdata_file")")
potential_config="/home/$user/public_html/wp-config.php" potential_config="/home/$user/public_html/wp-config.php"
@@ -583,6 +647,7 @@ case "$choice" in
fi fi
fi fi
done done
fi
if [ -z "$wp_config" ]; then if [ -z "$wp_config" ]; then
print_error "WordPress installation not found for $domain" print_error "WordPress installation not found for $domain"