There is an easy way to analyze Apache logs using grep and sed.
We can create different type of reports with the help of some simple commands.
I am taking following snippet of one Apache access log entry to explain scripts -
<IP of client> - - [20/Aug/2010:11:59:59 -0700] "GET <file name to get> HTTP/1.1" 404 330
1. Use following to get total number of request per hour on Apache.
grep "GET " <Apache log file Name> | sed -e 's/^.*2010://' | sed -e 's/:.*$//' | sort | uniq -c
This will help analyzing the traffic on our Apache server on any given point of time.
2. To get the total number of different HTTP response codes -
grep "GET " <Apache log file Name> | sed -e 's/^.*HTTP\/1.[0-9]" //' | sed -e 's/ .*$//' | sort | uniq -c
3. Now if we see that the traffic has been increased on any specific point of time. First thing comes into mind is that this traffic is real or any hacking attempt.
If the hacker is not smart enough and not using Zombies then we can see this by checking for total number of request from any specific IP -
grep "GET " <Apache log file Name> | sed -e 's/ - - .*$//' | sort | uniq -c
This can help us understand the trend on traffic on our site.
No comments:
Post a Comment