views:

64

answers:

3

I'm looking to retroactively parse the logs and count the number of /foo/* requests that have occurred to have a baseline benchmark for a new feature that we're pushing. A simple command line script would be fine -- with an added bonus for being able to specify a date-range.

Some use of grep, perhaps?

+1  A: 
egrep -c '\] "[A-Z]+ /foo/' access_log
chaos
+1  A: 

Adding the "able to specify a date range" condition makes it a little harder. Easiest probably to write a Python or Ruby program. Otherwise, using date(1) with -f to set up the parsing format, -j to tell it to leave the damn clock alone, and -r to have it print seconds since epoch would get you there.

Charlie Martin
A: 
fgrep " /foo/" access_log | wc -l

to get a roughly formatted accesses per day:

fgrep " /foo/" access_log | cut -d'[' -f2 | cut -d: -f1 | uniq -c
Michael Cramer