diff --git a/modules/security/bot-analyzer.sh b/modules/security/bot-analyzer.sh index bfc1153..d011c54 100755 --- a/modules/security/bot-analyzer.sh +++ b/modules/security/bot-analyzer.sh @@ -322,8 +322,11 @@ parse_logs() { if [ "$INTERWORX_MODE" = "yes" ]; then # InterWorx: extract from path /home/user/var/domain.com/logs/transfer.log domain=$(echo "$logfile" | sed -n 's|^/home/.*/var/\([^/]*\)/logs/.*|\1|p') + elif [ "$SYS_CONTROL_PANEL" = "plesk" ]; then + # Plesk: extract from path /var/www/vhosts/system/domain.com/logs/access_log + domain=$(echo "$logfile" | sed -n 's|^/var/www/vhosts/system/\([^/]*\)/logs/.*|\1|p') else - # cPanel: extract from filename + # cPanel: extract from filename /var/log/apache2/domlogs/domain.com or domain.com-ssl_log domain=$(basename "$logfile" | sed 's/-ssl_log$//') fi @@ -1867,13 +1870,40 @@ main() { log_count=$(find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | wc -l) if [ "$log_count" -eq 0 ]; then - print_alert "Error: No log files found in $LOG_DIR" - if [ -n "$HOURS_BACK" ]; then - echo "No logs found from the last $HOURS_BACK hours" - elif [ -n "$DAYS_BACK" ]; then - echo "No logs found from the last $DAYS_BACK days" + # Try without time filter to see if ANY logs exist + local total_logs=$(find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" 2>/dev/null | wc -l) + + if [ "$total_logs" -eq 0 ]; then + print_alert "Error: No log files found in $LOG_DIR" + echo "" + echo "Diagnostic information:" + echo " Log directory: $LOG_DIR" + echo " Directory exists: $([ -d "$LOG_DIR" ] && echo "yes" || echo "no")" + if [ -d "$LOG_DIR" ]; then + echo " Total files in directory: $(find "$LOG_DIR" -type f 2>/dev/null | wc -l)" + echo " Sample files:" + find "$LOG_DIR" -type f 2>/dev/null | head -5 | sed 's/^/ /' + fi + echo "" + echo "Control panel: $SYS_CONTROL_PANEL" + exit 1 + else + print_alert "No logs found matching time filter" + if [ -n "$HOURS_BACK" ]; then + echo "No logs found from the last $HOURS_BACK hours" + elif [ -n "$DAYS_BACK" ]; then + echo "No logs found from the last $DAYS_BACK days" + fi + echo "Total logs available: $total_logs" + echo "" + read -p "Analyze all available logs instead? [y/N]: " choice + if [[ "$choice" =~ ^[Yy] ]]; then + log_count=$total_logs + find_opts=() # Clear time filter + else + exit 0 + fi fi - exit 1 fi print_info "Found $log_count log files to analyze"