Re: log file conversion (OT?)
On 11/9/05, Giorgos Keramidas [EMAIL PROTECTED] wrote: On 2005-11-09 13:44, Bart Silverstrim [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote: Yes. Perl should work fine here. $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 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. 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=strftime -ane \ '$F[0] = strftime %Y-%m-%d %H:%M:%S, (localtime($F[0])); \ print join( , @F) . \n;' -- Regards, Doug ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: log file conversion (OT?)
On 2006-01-03 14:05, Doug Poland [EMAIL PROTECTED] wrote: I wrote some time ago: $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 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. 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=strftime -ane \ '$F[0] = strftime %Y-%m-%d %H:%M:%S, (localtime($F[0])); \ print join( , @F) . \n;' You're most welcome, of course :) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
log file conversion (OT?)
I have Squid running on a FreeBSD system and the log file (access.log) has lines like 1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET http://www.urprize2.com/adv77/images/header_08_23_05.gif - NONE/- image/gif 1131556815.584 47 172.16.2.153 TCP_HIT/200 1828 GET http://www.urprize2.com/adv77/images/timer.swf - NONE/- application/x-shockwave-flash in it. Is there a simple way or a one- or two-liner script that can take the epoch time in the first column and replace it with the actual time/date stamp in human-readable format? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: log file conversion (OT?)
On 2005-11-09 12:36, Bart Silverstrim [EMAIL PROTECTED] wrote: I have Squid running on a FreeBSD system and the log file (access.log) has lines like 1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET http://www.urprize2.com/adv77/images/header_08_23_05.gif - NONE/- image/gif 1131556815.584 47 172.16.2.153 TCP_HIT/200 1828 GET http://www.urprize2.com/adv77/images/timer.swf - NONE/- application/x-shockwave-flash in it. Is there a simple way or a one- or two-liner script that can take the epoch time in the first column and replace it with the actual time/date stamp in human-readable format? Yes. Perl should work fine here. $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 172.153 TCP_HIT/200 35674 GET PS: Please, ignore the automatically forced 'footer' below, until I find a way to post messages without crap added automatically by the Exchange relay I'm forced to use these days. - This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, do not forward this email to any other person, delete this e-mail and destroy all copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: log file conversion (OT?)
On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote: On 2005-11-09 12:36, Bart Silverstrim [EMAIL PROTECTED] wrote: I have Squid running on a FreeBSD system and the log file (access.log) has lines like 1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET http://www.urprize2.com/adv77/images/header_08_23_05.gif - NONE/- image/gif 1131556815.584 47 172.16.2.153 TCP_HIT/200 1828 GET http://www.urprize2.com/adv77/images/timer.swf - NONE/- application/x-shockwave-flash in it. Is there a simple way or a one- or two-liner script that can take the epoch time in the first column and replace it with the actual time/date stamp in human-readable format? Yes. Perl should work fine here. $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 172.153 TCP_HIT/200 35674 GET Is there a way to get it to take in each line of the logfile and output it to a new file? It wouldn't be as easy as a cat access.log | (perl code here) newfile.log would it? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: log file conversion (OT?)
On 2005-11-09 13:44, Bart Silverstrim [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote: Yes. Perl should work fine here. $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 172.153 TCP_HIT/200 35674 GET Is there a way to get it to take in each line of the logfile and output it to a new file? It wouldn't be as easy as a cat access.log | (perl code here) newfile.log would it? Of course it would :) This is why I used the -pe option when I wrote the script above, to make sure that Perl acts as a 'filter'. - Giorgos PS: Please, ignore the automatically forced 'footer' below, until I find a way to post messages without crap added automatically by the Exchange relay I'm forced to use these days. - This e-mail and any attachments may contain confidential and privileged information. If you are not the intended recipient, please notify the sender immediately by return e-mail, do not forward this email to any other person, delete this e-mail and destroy all copies. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: log file conversion (OT?)
On Nov 9, 2005, at 1:48 PM, Giorgos Keramidas wrote: On 2005-11-09 13:44, Bart Silverstrim [EMAIL PROTECTED] wrote: On Nov 9, 2005, at 1:03 PM, Giorgos Keramidas wrote: Yes. Perl should work fine here. $ echo '1131556815.537101 172.16.2.153 TCP_HIT/200 35674 GET' | \ perl -MPOSIX=strftime \ -pe 'chomp; @x=split /\./; \ $ts = strftime %Y-%m-%d %H:%M:%S, (localtime($x[0])); \ $_=$ts...join(.,@x[1,$#x]).\n;' 2005-11-09 09:20:15.537101 172.153 TCP_HIT/200 35674 GET Is there a way to get it to take in each line of the logfile and output it to a new file? It wouldn't be as easy as a cat access.log | (perl code here) newfile.log would it? Of course it would :) This is why I used the -pe option when I wrote the script above, to make sure that Perl acts as a 'filter'. - Giorgos Thank you, I'll give it a try as soon as I can :-) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]