Our analytics software monitors the HTML pages that we're serving quite nicely (through embedded javascript) but we have a few image files that are not included in these reports as they're not attached to any HTML. Knowing the file's name/path, I'm looking for quick (and dirty if necessary) way to identify how many times a given image was served by Apache on each Day (or hour?).

link|improve this question

47% accept rate
feedback

2 Answers

up vote 1 down vote accepted

You will need to look at your particular log format, but as an example:

grep '/foo.jpg' /var/log/access.log | grep '11/May' | wc -l
link|improve this answer
i'm using: grep -c "/images/foo.jpg" /var/log/apache2/access_log and it gives me the count – Meltemi May 13 '10 at 15:57
feedback

Quick and dirty: grep for the image in the access log.

Number of times in a day = number of lines containing that pattern (assuming you roll your logs daily).
Number of times in an hour/minute/morning/afternoon/etc. gets a bit more complex but is still easily accomplished with some creative perl or shell scripting (the particulars of which depend on your log format)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.