httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danijel Tasov <apache-us...@kobalt.ath.cx>
Subject Re: [users@httpd] Apache logs into PostgreSQL in realtime
Date Wed, 18 Jan 2006 10:26:41 GMT
Michelle Konzack wrote:
> What I need is a program/script which can put the log
> directly into the PostgreSQL for Real-Time analysis.

I'm using perls Text::ParseWords for doing this:

If you have the classic combined LogFormat:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

You can do:

use Text::ParseWords;
use DBI;
# Database connect here

while(<>) {
  my ($remote_host, $logname, $authuser, $time, $request,
  $status, $size, $referer, $user_agent) = quotewords(/\s+/, 0, $_)
  $dbh->do("INSERT ..."); 
}

$time can be easily converted by using HTTP::Date.

bye,
DaTa

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message