Re: httpd to squid native log format convertor?

From: Peter Reif <[email protected]>
Date: Fri, 07 Jan 2000 09:39:06 +0100

naimi wrote:
>
> Hi all,
> We had set up our squid log format as httpd_log_format. But most squid log
> analyzers work on "squid native log format". Does anybody knows a utility or
> script for converting httpd log format to squid native log format?
> Thank in advance.

I wrote a script that works the other way round, it converts native
log-format to httpd log. This is because native format contains more
information (e.g. request time in milliseconds). The only field I have
to guess is the HTTP-protocol, (I assume HTTP/1.0), it is only logged in
http log format.

Peter

#!/usr/bin/perl

use Time::Local;

$timedist = timelocal(localtime) - timelocal(gmtime);
$timedist /= 36;
$timedist = sprintf ("%+05d", $timedist);

# Rfc822 Date
# von advcgi kopiert und veraendert
sub Date822 {
   my ($s, $i, $h, $d, $m, $y, $w, $a, $z) = (gmtime($_[0]));
   $h = sprintf("%02d:%02d:%02d", ($h, $i, $s));
   $d = sprintf("%02d", ($d));
   $m = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
      'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')[$m];
   $y += 1900;
   return "$d/$m/$y:$h $timedist";
}

while (<>) {
        my ($zeit, $client, $cache_code, $code, $size, $method, $url, $ident, $hier_code, $content) = m#(\d+).\d+\s+\d+\s+(\S+)\s+([^/]+)/(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)#;
        $datum = Date822 ($zeit);
        print "$client $ident - [$datum] \"$method $url HTTP/1.0\" $code $size $cache_code:$hier_code\n";
}
Received on Fri Jan 07 2000 - 01:55:49 MST

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