« Home | Scripts for all occasions » | Bash shell option » | Get the hidden files » | Chrooted SSH HowTo » | How to create IP-IP tunnel between FreeBSD and Lin... » | How can I have two default routes? » | Revealing your routing tables » | Where do the IP addresses come from? » | Just what is routing? » | Mysql Database Backup Script » 

Monday, March 20, 2006 

Who hits my website

This will generate a listing of all IPs that have accessed a specific directory of my website
(the /foo/ directory), and print a count (from greatest to least) next to the IP.

if you want to get a total listing for all directories of a domain, just omit the "grep -e /foo/" statement.

cat /home/server.com/logs/access_log |
grep -e /flesh/ |
sort |
uniq -w15 -c |
cut -f 1 -d- |
sort -r -g


Using this format for the apache log files:
63.26.57.218 - - [07/Mar/2001:21:12:15 -0500] "GET
/flesh/fleshpix/thumbs/facial2/poofylips.jpg_t.jpg HTTP/1.1" 200 4353


Sample output is:
123 62.155.255.18
123 216.17.9.140
121 62.98.129.125
120 66.32.16.55
120 216.196.144.202
119 194.100.2.65
116 194.170.1.68
114 62.155.255.21

Links to this post

Create a Link