Wednesday, April 22, 2009

Analyze apache log with awk

Lets say we want to find the amount of times a specific ip address has hit your webserver,
on this example we are assuming your apache access_log is located in /usr/local/apache/logs

The full command would be:

awk '{print $1}' /usr/local/apache/logs/access.log | sort | uniq -c | sort -fr

and the output would be like this:

155 90.193.xx.xx
154 86.143.xx.xx
109 82.17.xx.xx
85 90.213.xx.xx
74 193.28.xx.xx

No comments:

Post a Comment