Skip to content

Instantly share code, notes, and snippets.

@joostvanveen
Last active March 22, 2018 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joostvanveen/59c73ac47ef97fb8c6cb4bc00aeb1ee7 to your computer and use it in GitHub Desktop.
Save joostvanveen/59c73ac47ef97fb8c6cb4bc00aeb1ee7 to your computer and use it in GitHub Desktop.
Display the top X visitors by IP address from a single or all nginx access log files
# Display the top 20 visitors by IP address from a single log file
awk '{print $2}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head -20
# Display the top 40 visitors by IP address from all rotated gzipped log files
zcat /var/log/nginx/access.log* | awk '{print $2}' | sort | uniq -c | sort -nr | head -40
# Find IP adrdresses for all users that created a custoter account for Magento
zcat /var/log/nginx/access.log* | awk -v OFS='\t' '/\/customer\/account\/createpost?/ {print $2, $21}' | sort | uniq -c | sort -nr | head -40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment