Christian Balzer wrote about converting dates with a filter.
Here's a quick bit of perl I knocked up to do the job - it might
be useful for someone else so I decided to un-lurk :-)
#!/usr/bin/perl
#
# Date Converting Filter - Simon Amor, 7th October 1996 <spa@dmu.ac.uk>
#
# Usage: cat access.log | ./dateconv.pl | less
#
while (<>) {
if (/^(\d+)(\..+)$/) {
$time=localtime($1);
print substr($time,0,11).substr($time,20,4).substr($time,10,9)."$2\n";
}
}
Save it out to a file (for example dateconv) and don't forget to change
the location of perl if you have to. Make it executable for yourself at
least and if you want, other people too.
To use it, simply do the following, assuming your current directory is where
the squid logs are stored and that the dateconv script is in your path.
cat access.log | dateconv | less
There you are, human-friendly times. Example output (with extra spaces):
Mon Oct 7 1996 06:25:16.105 111 washuu.swb.de TCP_HIT/200 11599 GET
http://www.unitedmedia.com/comics/dilbert/header.gif - NONE/-
Mon Oct 7 1996 06:25:17.050 1061 washuu.swb.de TCP_EXPIRED_MISS/200 7957
GET http://ad.doubleclick.net/ad/www.dilbert.com/ - SIBLING_HIT/washuu.swb.de
The milliseconds (I think) value is kept as in the original log, it just
converts the rest down to the nearest second.
Hope this is helpful,
Simon
-- Simon Amor | Voice: +44 (0)116 257 7156 Network & Communications Group | mailto:spa@dmu.ac.uk De Montfort University, Leicester,UK | http://www.dmu.ac.uk/~spa/Received on Mon Oct 07 1996 - 12:01:30 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:33:14 MST