From owner-freebsd-questions@FreeBSD.ORG  Tue Jan  3 20:05:38 2006
Return-Path: <owner-freebsd-questions@FreeBSD.ORG>
X-Original-To: freebsd-questions@freebsd.org
Delivered-To: freebsd-questions@freebsd.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A4FFB16A41F
	for <freebsd-questions@freebsd.org>;
	Tue,  3 Jan 2006 20:05:38 +0000 (GMT)
	(envelope-from wisco.disco@gmail.com)
Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0BF1743D45
	for <freebsd-questions@freebsd.org>;
	Tue,  3 Jan 2006 20:05:37 +0000 (GMT)
	(envelope-from wisco.disco@gmail.com)
Received: by zproxy.gmail.com with SMTP id 13so2570630nzp
	for <freebsd-questions@freebsd.org>;
	Tue, 03 Jan 2006 12:05:37 -0800 (PST)
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com;
	h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references;
	b=AzB9+nC5T4tFbgP2tWV/q2bjhM5k1HmOn4Qpx4xV4nDZnqNz4HfRcmw74xBmY9P2gahvuGeWn4C7muktnOXdHSaEa+fQiMV+w3z8dz5BTh4Ka43crYRf3Ruw8yEMmIzQj4b1PqU+A0Bw/8vIYY1rqfd1tGP4gEFcC2Ip71mdDHY=
Received: by 10.64.241.19 with SMTP id o19mr588496qbh;
	Tue, 03 Jan 2006 12:05:37 -0800 (PST)
Received: by 10.64.149.12 with HTTP; Tue, 3 Jan 2006 12:05:37 -0800 (PST)
Message-ID: <eae8cb0a0601031205w2327ff48qf5c9d764c5a3112@mail.gmail.com>
Date: Tue, 3 Jan 2006 14:05:37 -0600
From: Doug Poland <wisco.disco@gmail.com>
To: Giorgos Keramidas <keramida@ceid.upatras.gr>
In-Reply-To: <20051109184814.GA57162@flame.pc>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
References: <06fe145ebc265841b4c499f5dc1e72ab@athensasd.org>
	<20051109180353.GA10584@flame.pc>
	<c3593d564c07405fc09bd0e370319c1b@athensasd.org>
	<20051109184814.GA57162@flame.pc>
Cc: Bart Silverstrim <bsilverstrim@athensasd.org>,
	freebsd-questions@freebsd.org
Subject: Re: log file conversion (OT?)
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: doug@polands.org
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions>
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
	<mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Tue, 03 Jan 2006 20:05:38 -0000

On 11/9/05, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On 2005-11-09 13:44, Bart Silverstrim <bsilverstrim@athensasd.org> wrote:
> > On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote:
> > >Yes.  Perl should work fine here.
> > >
> > >    $ echo '1131556815.537    101 172.16.2.153 TCP_HIT/200 35674 GET' =
| \
> > >      perl -MPOSIX=3Dstrftime \
> > >      -pe 'chomp; @x=3Dsplit /\./; \
> > >           $ts =3D strftime "%Y-%m-%d %H:%M:%S", (localtime($x[0])); \
> > >           $_=3D$ts.".".join(".",@x[1,$#x])."\n";'
> > >    2005-11-09 09:20:15.537    101 172.153 TCP_HIT/200 35674 GET
> >
Thank you, Giorgos, for that excellent Perl one-liner.  There is a
minor problem in that not all the input fields are output correctly.=20
Note the IP address is truncated.   I took the liberty of fixing and
simplifiing (or, obfuscating, depending on one's point of view)

tail -f /usr/local/squid/logs/access.log | \
  perl -MPOSIX=3Dstrftime -ane \
  '$F[0] =3D strftime "%Y-%m-%d %H:%M:%S", (localtime($F[0])); \
  print join(" ", @F) . "\n";'


--
Regards,
Doug