Search squid archive

RE: HowDo I: Get Date stamp on the access.log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John,
I was there a while ago so searched around the Web and came up with a
tool to help do this.  I use this in a logrotation script that runs each
night just before midnight so I have daily logs of access.  I also use a
script within this to convert IPs to host names so I know from what
computer the access is.  Here's what mine does:

Rotate access.log

Move the rotated log file to a log storage area and rename it to include
date

Convert IPs in log file to host names

Convert Unix time stamps in log file to normal date and time (My script
retains the original log file AND creates a new one with host names and
date/time)

Here is what is used to do the conversions:

IP -> Host Name:

perl <path to>/ip2name.pl -I <path to rotated>/access.log > <path
to>/<output_file>.log

Unix time conversion:

cat <path to>/rotated_access.log | perl <path to>/conv_date > <path
to>/output_file.log

In my setup the output file of the first is then the input file of the
2nd...

I don't think you can attach files here so I've pm'ed you and attached
the ip2name.pl and conv_date files in case they aren't readily found, I
forget where I found them, but I think they're around.

Here is the code of conv_date:

#! /usr/bin/perl -p
s/^\d+\.\d+/localtime $&/e;

If you're interested in my entire rotation script, I can provide that
also.  I'm no Linux wizard, still a beginner, but figured this stuff out
(somewhat) and it's working for me.

There may be some things you need to install for these to work, not sure
what I did.  You will also need to modify some things in ip2name (you'll
see some of my info in there, maybe referring to "ridge" which is part
of my domain name).  conv_date (which is what you're after anyway) is
good to go the way it is.  You can just pull out the cat..... piece
above and get what you want right away.

Hope this helps, and not more than you wanted!!

Geoff

-----Original Message-----
From: John Walubengo [mailto:jwalu@xxxxxxxxx] 
Sent: Friday, July 07, 2006 1:39 AM
To: Guido Serassio; Laurent Marc 00
Cc: squid-users@xxxxxxxxxxxxxxx
Subject: Re:  HowDo I: Get Date stamp on the access.log

Below is my sample access.log data:

1152258629.089  23364 172.16.32.80 TCP_MISS/200 4625 GET
http://www.pcreview.co.uk/template/vbulletin.css student
DIRECT/70.86.33.18 text/css

1152258629.261   2792 172.16.32.80 TCP_MISS/200 2570 GET
http://www.htmlgoodies.com/css/starlight/star-light.css
student DIRECT/63.236.73.67 text/css


It is basically the default log; how can i get it to show
the date:time stamp so that I get to know WHEN the users
accessed these sites?

walu.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux