Skip to content

Instantly share code, notes, and snippets.

@mccun934
Last active October 24, 2018 21:22
Show Gist options
  • Save mccun934/0d622a979bc1be7459fd0fa0665505de to your computer and use it in GitHub Desktop.
Save mccun934/0d622a979bc1be7459fd0fa0665505de to your computer and use it in GitHub Desktop.
Httpd log rate commands

From:

https://serverfault.com/questions/226982/how-to-measure-req-sec-by-analyzing-apache-logs

This great article helped me a lot...

http://www.inmotionhosting.com/support/website/server-usage/view-level-of-traffic-with-apache-access-log

I had created a set of prepered commands that I am using to analyze apache log:

request per hour

cat access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":00"}' | sort -n | uniq -c

request per hour by date

grep "23/Jan" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":00"}' | sort -n | uniq -c

request per hour by IP

grep "XX.XX.XX.XX" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":00"}' | sort -n | uniq -c

requests per minute:

cat access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort -nk1 -nk2 | uniq -c

requests per minute for date:

grep "02/Nov/2017" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort -nk1 -nk2 | uniq -c

requests per minute for url:

grep "[url]" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort -nk1 -nk2 | uniq -c

per IP per minute

grep "XX.XX.XX.XX" access.log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2":"$3}' | sort -nk1 -nk2 | uniq -c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment