lgrep June, 2002

GREP provides a more human-readable view of your web traffic than simply grepping through the raw server logs. It makes it easy to track individual user sessions, provide conditions so you only see the hits you are interested in, and customize the output however you like.

ere's what some typical output might look like:

 foobar.somewhere.net (98.99.100.101):
 bsr: Mozilla/5.0
 ref: www.google.com/search?hl=en&q=searchstring
   8:29: ~/mypage.html
   8:30: ~/anotherpage.html
   8:45: ~/yetanother.html
 ref: www.google.com/search?hl=en&q=happiness
  12:23: ~/happypage.html
  12:24: ~/sadpage.html
somecomputer.somewhereelse.com (12.13.14.15): bsr: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) ref: www.ugcs.caltech.edu/~mybestfriend/links.html 8:39: ~/ 8:42: ~/etc.html

o give you an idea of the sorts of things you can do, here are some usage examples:

 # show only form submissions
 lgrep bret '$request =~ /^POST/'
# show only Mozilla users and don't show image files lgrep bret nopics '$browser =~ /mozilla/i'
# show only non-OK hits, prefixed with the response code lgrep bret bad '$print = " $response: "'
# show all server activity at noon today lgrep - '$time eq "12:00"'
# design your own custom output format lgrep bret quiet '$println = "$date $time: $page"'
# just print a count of unique human visitors lgrep bret quiet nobots '${z}{$ipaddr}++; $end = keys %z'
# see what perverted things people like to websearch lgrep sex quiet '$println = $search'

ocumentation is at the top of the source code.

Download lgrep.pl (v1.0, 12 Kb)