#!/bin/bash # Configuration LOG_FILE="/var/log/nginx/access.log" TOP_COUNT=10 if [ ! -f "$LOG_FILE" ]; then echo "Error: Log file '$LOG_FILE' not found." exit 1 fi echo "Top $TOP_COUNT IP Addresses requesting your website:" awk '{print $1}' "$LOG_FILE" | sort | uniq -c | sort -nr | head -n "$TOP_COUNT" echo " Top $TOP_COUNT Requested URLs:" awk '{print $7}' "$LOG_FILE" | sort | uniq -c | sort -nr | head -n "$TOP_COUNT" echo " Top $TOP_COUNT User Agents:" awk -F'"' '{print $6}' "$LOG_FILE" | sort | uniq -c | sort -nr | head -n "$TOP_COUNT" echo " Top $TOP_COUNT HTTP Status Codes:" awk '{print $9}' "$LOG_FILE" | sort | uniq -c | sort -nr | head -n "$TOP_COUNT"