Re: [SQU] Time in log files

From: Robin Stevens <robin.stevens@dont-contact.us>
Date: Wed, 3 Jan 2001 10:49:22 +0000

On Wed, Jan 03, 2001 at 08:38:19AM +1000, Tony Melia wrote:
> Is it possible to patch squid, or even add an option in the config, so
> that it will report times in actual time rather than epoch in it’s log
> files? I have a relatively low traffic site using squid, and would like
> to leave a ‘tail –f /var/log/squid/access.log’ command running so I
> can watch realtime, but also see the real time.

My standard method is to pipe the logs into the following perl script,
which converts times to standard format and resolves IP addresses:

#!/usr/local/bin/perl
use Socket;
while (<>) {
    @in = split();
    $time = scalar gmtime $in[0];
    if ($hosts{"$in[2]"} eq "") {
         $hosts{"$in[2]"}=((gethostbyaddr(inet_aton("$in[2]"),AF_INET))[0]);
    }
    $host=$hosts{"$in[2]"};
    $_ =~ s/$in[0]/$time/;
    $_ =~ s/$in[2]/$host/;
    print $_;
}

-- 
--------------- Robin Stevens  <robin.stevens@oucs.ox.ac.uk> -----------------
Oxford University Computing Services  http://www-astro.physics.ox.ac.uk/~rejs/
 (+44)(0)1865: 726796 (home) 273212 (work)  273275 (fax)  Mobile: 07776 235326
--
To unsubscribe, see http://www.squid-cache.org/mailing-lists.html
Received on Wed Jan 03 2001 - 03:52:16 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:57:19 MST