libapache-dbilogger-perl-0.93.orig/ 40755 1750 62 0 6607053673 16125 5ustar mdormanstafflibapache-dbilogger-perl-0.93.orig/bin/ 40755 1750 62 0 6607053673 16675 5ustar mdormanstafflibapache-dbilogger-perl-0.93.orig/bin/moverows.pl100755 1750 62 1771 6542777641 21227 0ustar mdormanstaff#!/usr/bin/perl use DBI; use Getopt::Std; use vars qw($dbh); getopts("dc:m", \%opts); # # Moves rows from 'requests_insert' to 'requests' in the database # $Id: moverows.pl,v 1.1 1998/06/20 18:29:53 ask Exp $ my $conffile = $opts{c} || "./webstat.conf"; require $conffile; sub sqldo { my $sqlcommand = shift; my $sth = $dbh->prepare($sqlcommand); die "Could not prepare [$DBI::errstr] ($sqlcommand)" unless $sth; my $rv = $sth->execute; die "Could not execute [$DBI::errstr] ($sqlcommand)" unless $rv; $sth->finish; } $dbh = DBI->connect("DBI:$WebStat::Config::database{driver}:$WebStat::Config::database{database}:$WebStat::Config::database{host}", "$WebStat::Config::database{user}", "$WebStat::Config::database{password}" ); die "Cannot connect to database: $DBI::errstr ($!)" unless $dbh; sqldo("LOCK TABLES requests WRITE, requests_insert WRITE"); sqldo("insert into requests select * from requests_insert"); sqldo("delete from requests_insert"); sqldo("UNLOCK TABLES"); $dbh->disconnect; libapache-dbilogger-perl-0.93.orig/bin/webstat.conf100644 1750 62 2720 6557661620 21314 0ustar mdormanstaff# # Configurationfile for webstat # $Id: webstat.conf,v 1.2 1998/07/29 18:01:52 ask Exp $ # # possible keywords in the server hash: # alias => arrayref to a list of servernames # description => scalar with a description of the site # urlpath = scalar, regexp to the wanted urlpath (like "^/~ask/" for my pages) # mail => hashref # rcpt => arrayref to a list of recipients # frequency => scalar (weekly, daily, monthly) # not at all implemented # # The 'default' server provides default values # Only 'default' mail rcpt's will get mail in test (-T) mode # package WebStat::Config; use vars qw(%server %database); %database = ( driver => 'mysql', host => 'ratatosk', user => 'stats', password => 'seeekrit', database => 'httpdlog', table => 'requests' ); $server{default} = { mail => { frequency => "daily", rcpt => [qw(ask@netcetera.dk)], from => 'netpasser@netcetera.dk' } }; $server{"www.hillerod-posten.dk"} = { alias => [ qw(www.hip.dk www.hilleroed-posten.dk) ], mail => {rcpt => [qw(ask@netcetera.dk stoffer@netcetera.dk)]} }; $server{"www.plys.net"} = { description => "Shareware bladet", urlpath => "^/~swb/", mail => {rcpt => [qw(ask@netcetera.dk swb@get2net.dk)]} }; $server{"www.plys.net"} = { mail => { rcpt => [ qw(netpasser@netcetera.dk) ]} }; $server{"www.multimesserne.dk"} = { alias => [ qw(www.multimediamessen.dk www.multimix.dk) ], mail => { rcpt => [ qw(netpasser@netcetera.dk) ]} }; 1; libapache-dbilogger-perl-0.93.orig/bin/webstat_resolver.pl100755 1750 62 3373 6567767547 22753 0ustar mdormanstaff#!/usr/bin/perl use strict; use DBI; use Getopt::Std; use vars qw($dbh %opts); use Net::DNS; getopts("dc:m", \%opts); # # Moves rows from 'requests_insert' to 'requests' in the database # $Id: webstat_resolver.pl,v 1.1 1998/08/23 10:31:03 ask Exp $ my $conffile = $opts{c} || "./webstat.conf"; require $conffile; sub sqldo { my $sqlcommand = shift; # print "$sqlcommand\n"; # return; my $sth = $dbh->prepare($sqlcommand); die "Could not prepare [$DBI::errstr] ($sqlcommand)" unless $sth; my $rv = $sth->execute; die "Could not execute [$DBI::errstr] ($sqlcommand)" unless $rv; $sth->finish; } $dbh = DBI->connect("DBI:$WebStat::Config::database{driver}:$WebStat::Config::database{database}:$WebStat::Config::database{host}", "$WebStat::Config::database{user}", "$WebStat::Config::database{password}" ); die "Cannot connect to database: $DBI::errstr ($!)" unless $dbh; my $table = "requests_insert"; my $sth = $dbh->prepare(qq[select remoteip from $table \ where remotehost = '' group by remoteip]); die "Could not prepare [$DBI::errstr]" unless $sth; my $rv = $sth->execute; die "Could not execute [$DBI::errstr]" unless $rv; while (my ($remoteip) = $sth->fetchrow) { my $res = new Net::DNS::Resolver; print "$remoteip "; my $query = $res->search($remoteip, "PTR"); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "PTR"; my $name = $rr->rdatastr; $name =~ s/\.$//; print "= $name\n"; sqldo(qq[update $table set remotehost="$name" where remoteip="$remoteip"]); last; } } else { print "failed: ", $res->errorstring, "\n"; next unless ($res->errorstring eq "NXDOMAIN"); sqldo(qq[update $table set remotehost='unresolved' where remoteip="$remoteip"]); } } $sth->finish; $dbh->disconnect; libapache-dbilogger-perl-0.93.orig/bin/webstat_mail.pl100755 1750 62 17556 6607051172 22033 0ustar mdormanstaff#!/usr/bin/perl -w use strict; use DBI; use Carp; use vars qw(%opts %conf); use Getopt::Std; use Data::Dumper; use Date::Format; use Net::SMTP; getopts("dtc:MTh", \%opts); &usage if ($opts{h}); &readconfigfile; my $dbh = DBI->connect("DBI:$WebStat::Config::database{driver}:$WebStat::Config::database{database}:$WebStat::Config::database{host}", "$WebStat::Config::database{user}", "$WebStat::Config::database{password}" ); die "Cannot connect to database: $DBI::errstr ($!)" unless $dbh; $dbh->do("set SQL_BIG_TABLES=1"); # for each server: do something.. while( my ($server, $serverconfig) = each %WebStat::Config::server) { next if ($server eq "default"); print "$server\n" if $opts{d}; #print Data::Dumper->Dump([\$serverconfig], [qw($serverconfig)]) if $opts{d}; # setup a few useful dates my %dates = ( today => time2str("%Y-%m-%d", time), yesterday => time2str("%Y-%m-%d", time-(60*60*24)), weekago => time2str("%Y-%m-%d", time-(60*60*24*7)), monthago => time2str("%Y-%m-%d", time-(60*60*24*30)) ); my %stats; my $serverquery; unless ($serverconfig->{alias}) { $serverquery=qq[server="$server"]; } else { # $serverquery=qq[(server="]. join ('" or server="', $server,@{$serverconfig->{alias}}) .qq[")]; $serverquery= qq[server in ("]. join ('","', $server,@{$serverconfig->{alias}}) . qq[")]; } if ($serverconfig->{urlpath}) { $serverquery .= qq[ and urlpath regexp "$serverconfig->{urlpath}"]; } # check things if ($opts{t}) { $stats{today} = CountThings($dates{today}, $serverquery); } else { $stats{daily} = CountThings($dates{yesterday}, $serverquery); $stats{weekly} = CountThings($dates{weekago}, $serverquery); $stats{monthly} = CountThings($dates{monthago}, $serverquery); } # print or mail it ... my $data; $data .= "Statistics for $server"; $data .= " [$serverconfig->{urlpath}]" if $serverconfig->{urlpath}; $data .= " ($serverconfig->{description})" if $serverconfig->{description}; $data .= "\n"; # for the output below.. $dates{daily} = $dates{yesterday}; $dates{weekly} = $dates{weekago}; $dates{monthly} = $dates{monthago}; for my $time ($opts{t} ? "today" : qw(daily weekly monthly)) { $data .= "\n$time (from $dates{$time})\n"; $data .= sprintf(" % 3u users, % 5u hits % 8.0fKB\n", $stats{$time}{usercount}, $stats{$time}{hits}, $stats{$time}{traffic}); #$data .= " $stats{$time}{pagehits} pageviews ($stats{$time}{pagetraffic}KB)\n"; } $data .= "\n"; my $timequery; unless ($opts{t}) { $timequery = qq[(timeserved >= "$dates{yesterday}" and timeserved < "$dates{today}")]; } else { $timequery = qq[(timeserved >= "$dates{today}")]; } $data .= "\nTop 20 domains visiting the site:\n"; $data .= " Hits Domain\n"; my $sqlcommand = qq[select substring(remotehost,locate(".",remotehost)+1,100) as subdims,\ remoteip,count(remotehost) as c from $WebStat::Config::database{"table"} \ where $serverquery and $timequery group by subdims order by c DESC LIMIT 20]; print "sqlcommand: $sqlcommand\n" if $opts{d}; my $sth = DoSql($sqlcommand); while (my ($subhost, $remoteip, $count) = $sth->fetchrow) { $subhost = "unresolved" unless ($subhost); $data .= sprintf(" % 5u: %s\n", $count, $subhost); } print "$data" unless ($opts{M}); if ($opts{M}) { my $smtp = Net::SMTP->new('smtp'); die "Could not connect to smtp server" unless ($smtp); my $mailfrom = $serverconfig->{mail}->{from} ? $serverconfig->{mail}->{from} : $WebStat::Config::server{"default"}->{mail}->{from}; $smtp->mail($mailfrom); my @mailto = $opts{T} ? @{$WebStat::Config::server{"default"}->{mail}->{rcpt}} : @{$serverconfig->{mail}->{rcpt}}; $smtp->to(@mailto); $smtp->data(); $smtp->datasend("From: $mailfrom\n"); $smtp->datasend("To: ". join (", ", @mailto)."\n" ); $smtp->datasend("Subject: Webstats for $server (". time2str("%Y-%m-%e", time) .")\n\n"); $smtp->datasend("$data\n"); $smtp->dataend(); $smtp->quit; } } # # Count users, hits and more for from the given period .. # args: $fromtime, $serverquery # returns: a hash with "the stats" (read the source :) ) sub CountThings { my ($fromtime, $serverquery) = @_; my ($sth, $timequery); my $table = $WebStat::Config::database{"table"}; my $today = time2str("%Y-%m-%e", time); unless ("$fromtime" eq "$today") { $timequery = qq[(timeserved >= "$fromtime" and timeserved < "$today")]; } else { $timequery = qq[(timeserved >= "$fromtime")]; } my %stat; # hits $sth = DoSql(qq[select count(server),sum(bytes)/1024 from $table where $serverquery and $timequery]); ($stat{hits}, $stat{traffic}) = $sth->fetchrow; ## pageviews # $sth = DoSql(qq[select count(server),sum(bytes)/1024 from $table where $serverquery # and $timequery # and (contenttype = 'text/plain' or contenttype = 'text/html')]); #($stat{pagehits}, $stat{pagetraffic}) = $sth->fetchrow; # users # use something like this to look at the "users" . # select server,urlpath,usertrack,remoteip,left(useragent,30),timeserved, # count(server) as c from requests where server="www.monsted.com" and timeserved # >= "1998-06-20" group by usertrack,remoteip order by remoteip; $sth = DoSql(qq[select count(server),remoteip from $table where $serverquery and $timequery group by usertrack]); $stat{usercount} = 0; my %visitors = (); while (my ($counts, $remoteip) = $sth->fetchrow) { # only count those who've looked at more than one page # (throw away spiders (and other who doesn't support cookies)) if ($counts > 1) { # count it, he support cookies $stat{usercount}++; } else { # remember the looser by hand $visitors{$remoteip}++; } } # add the noncookies if they hit more than one page (maybe we just should add them?) for my $count (values %visitors) { $stat{usercount}++ if ($count > 1); } return \%stat; } sub DoSql { my $sqlcommand = shift; print "sqlcommand: $sqlcommand\n" if $opts{d}; my $sth = $dbh->prepare($sqlcommand) or die "Could not prepare [$DBI::errstr] ($sqlcommand)"; $sth->execute or die "Could not execute [$DBI::errstr] ($sqlcommand)"; return $sth; } sub readconfigfile { my $conffile = $opts{c} || "./webstat.conf"; require $conffile; if ($opts{d}) { #print Data::Dumper->Dump([\%WebStat::Config::server], [qw(server)]); #print Data::Dumper->Dump([\%WebStat::Config::database], [qw(database)]); } } # count hits and traffic # select count(bytes) as hits,sum(bytes) as trafik,server from requests group by server order by hits limit 20 ; $dbh->disconnect; undef %WebStat::Config::server; exit; sub usage { print STDERR <prepare("select count(server),urlpath,referer from requests where referer not like ") # select count(server) as hits ,urlpath,referer from requests where referer not like CONCAT('http://', server, '%') order by hits desc limit 10 ; # THIS worked, I guess... #my $sqlcommand = qq[select count(server) as hits ,urlpath,referer,server from requests where \ # (referer like 'http://%' or referer = '') and not (referer like CONCAT('http://', server, '%') \ # or referer like CONCAT('http://www.hip.dk/%') or referer like CONCAT('http://www.hilleroed-posten.dk/%') ) \ # and server='www.hillerod-posten.dk' group by referer,server order by hits desc limit 10]; while (my $r = $sth->fetchrow_hashref) { print qq($r->{hits}, $r->{urlpath}, $r->{referer}\n); } libapache-dbilogger-perl-0.93.orig/TODO100644 1750 62 451 6607052427 16666 0ustar mdormanstaff Patches are welcome, send them to ask@netcetera.dk, thanks! - Documentation for the stat scripts - webstat_web.pl script - real tests - some options for what we want to log - webstat_mail should count the top 20 in users, not hits - make install should install the scripts somewhere libapache-dbilogger-perl-0.93.orig/MANIFEST100644 1750 62 213 6607052151 17315 0ustar mdormanstaffChanges DBILogger.pm MANIFEST Makefile.PL test.pl README bin/moverows.pl bin/webstat.conf bin/webstat_mail.pl bin/webstat_resolver.pl TODO libapache-dbilogger-perl-0.93.orig/Makefile.PL100644 1750 62 1114 6607053347 20167 0ustar mdormanstaffuse ExtUtils::MakeMaker; sub MY::dist { package MY; # so that "SUPER" works right my $inherited = shift->SUPER::dist(@_); $inherited .= "\nSCP = scp\n"; $inherited; } sub MY::dist_core { package MY; my $inherited = shift->SUPER::dist_core(@_); $inherited .= <<'EOT'; mydist : tardist copydist copydist : EOT $inherited .= "\t".'$(SCP) $(DISTVNAME).tar$(SUFFIX) s:/home/ftp/pub/perl/'; $inherited; } WriteMakefile( 'NAME' => 'Apache::DBILogger', 'VERSION_FROM' => 'DBILogger.pm', # finds $VERSION 'dist' => {COMPRESS => 'gzip', SUFFIX => '.gz'} ); libapache-dbilogger-perl-0.93.orig/Changes100644 1750 62 3557 6607053434 17522 0ustar mdormanstaffRevision history for Apache::DBILogger 0.93 Thu Oct 8 1998 ask - [webstat] Moved webstat.pl to webstat_mail.pl - [webstat] Correct address in From: header - [webstat] Added webstat_resolver.pl - a little script to resolve logrows without 'remotehost' - [webstat] Now also lists the top 20 domains visiting the site - [webstat] .. and other minor changes 0.92 Wed Jul 29 1998 ask - Added moverows.pl, webstat.pl and webstat.conf to the bin/ directory. - Fixed some flaws in the table defination in the pod section. (thanks to Lupe Christoph) - Now sets $r to shift->last. This should stop the problems with a wrong contenttype being logged. - Gets the usertrack cookie from $r->notes. 0.91 Sat Jun 20 1998 ask - If the 'Apache' cookie is set (from mod_usertrack) then log it to the 'usertrack' field. 0.90 Fri Jun 19 1998 ask - Updated documentation, fixing pod errors and more - More testing done (hence the upgrade in the version number) 0.85 Fri Jun 19 1998 ask - DBILogger_table option. Defaults to 'requests' - Updated documentation about requests_insert 0.84 Tue Jun 9 1998 ask - Optimized the reconnect some - Disabled the reconnect thingy - Added logging of contenttype - Added TRAPS section to documentation 0.83 Tue May 26 1998 ask - Retry and not just reconnect on connection loss 0.82 Sat May 23 1998 ask - Oops, 'warn' should be $r->log_error 0.81 Tue May 19 1998 ask - Adding '' and not NULL as referer if none is found - Added a little reconnect function (trying to get rid of these annoying Lost connection messages). 0.80 Sun May 5 1998 ask - Changed dbh->do to ->prepare, ->execute to beable to log more errors. 0.20 Sun Mar 22 1998 ask - Updated documentation - Added error handling in the connect stage. (Wow, 'safe' programming ...) - More testing 0.01 Thu Mar 12 1998 ask - original version libapache-dbilogger-perl-0.93.orig/DBILogger.pm100644 1750 62 17767 6607053513 20351 0ustar mdormanstaffpackage Apache::DBILogger; require 5.004; use strict; use Apache::Constants qw( :common ); use DBI; use Date::Format; $Apache::DBILogger::revision = sprintf("%d.%02d", q$Revision: 1.20 $ =~ /(\d+)\.(\d+)/o); $Apache::DBILogger::VERSION = "0.93"; sub reconnect($$) { my ($dbhref, $r) = @_; $$dbhref->disconnect; $r->log_error("Reconnecting to DBI server"); $$dbhref = DBI->connect($r->dir_config("DBILogger_data_source"), $r->dir_config("DBILogger_username"), $r->dir_config("DBILogger_password")); unless ($$dbhref) { $r->log_error("Apache::DBILogger could not connect to ".$r->dir_config("DBILogger_data_source")." - ".$DBI::errstr); return DECLINED; } } sub logger { my $r = shift->last; my $s = $r->server; my $c = $r->connection; my %data = ( 'server' => $s->server_hostname, 'bytes' => $r->bytes_sent, 'filename' => $r->filename || '', 'remotehost'=> $c->remote_host || '', 'remoteip' => $c->remote_ip || '', 'status' => $r->status || '', 'urlpath' => $r->uri || '', 'referer' => $r->header_in("Referer") || '', 'useragent' => $r->header_in('User-Agent') || '', 'timeserved'=> time2str("%Y-%m-%d %X", time), 'contenttype' => $r->content_type || '' ); if (my $user = $c->user) { $data{user} = $user; } $data{usertrack} = $r->notes('cookie') || ''; my $dbh = DBI->connect($r->dir_config("DBILogger_data_source"), $r->dir_config("DBILogger_username"), $r->dir_config("DBILogger_password")); unless ($dbh) { $r->log_error("Apache::DBILogger could not connect to ".$r->dir_config("DBILogger_data_source")." - ".$DBI::errstr); return DECLINED; } my @valueslist; foreach (keys %data) { $data{$_} = $dbh->quote($data{$_}); push @valueslist, $data{$_}; } my $table = $r->dir_config("DBILogger_table") || 'requests'; my $statement = "insert into $table (". join(',', keys %data) .") VALUES (". join(',', @valueslist) .")"; my $tries = 0; TRYAGAIN: my $sth = $dbh->prepare($statement); unless ($sth) { $r->log_error("Apache::DBILogger could not prepare sql query ($statement): $DBI::errstr"); return DECLINED; } my $rv = $sth->execute; unless ($rv) { $r->log_error("Apache::DBILogger had problems executing query ($statement): $DBI::errstr"); # unless ($tries++ > 1) { # &reconnect(\$dbh, $r); # goto TRYAGAIN; # } } $sth->finish; $dbh->disconnect; OK; } # #perl pun: windows is for users who can't handle the power of the mac. sub handler { shift->post_connection(\&logger); return OK; } 1; __END__ =head1 NAME Apache::DBILogger - Tracks what's being transferred in a DBI database =head1 SYNOPSIS # Place this in your Apache's httpd.conf file PerlLogHandler Apache::DBILogger PerlSetVar DBILogger_data_source DBI:mysql:httpdlog PerlSetVar DBILogger_username httpduser PerlSetVar DBILogger_password secret PerlSetvar DBILogger_table requests Create a database with a table named B like this: CREATE TABLE requests ( server varchar(127) DEFAULT '' NOT NULL, bytes mediumint(9) DEFAULT '0' NOT NULL, user varchar(15) DEFAULT '' NOT NULL, filename varchar(200) DEFAULT '' NOT NULL, remotehost varchar(150) DEFAULT '' NOT NULL, remoteip varchar(15) DEFAULT '' NOT NULL, status smallint(6) DEFAULT '0' NOT NULL, timeserved datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, contenttype varchar(50) DEFAULT '' NOT NULL, urlpath varchar(200) DEFAULT '' NOT NULL, referer varchar(250) DEFAULT '' NOT NULL, useragent varchar(250) DEFAULT '' NOT NULL, usertrack varchar(100) DEFAULT '' NOT NULL, KEY server_idx (server), KEY timeserved_idx (timeserved) ); Its recommended that you include use Apache::DBI; use DBI; use Apache::DBILogger; in your startup.pl script. Please read the Apache::DBI documentation for further information. =head1 DESCRIPTION This module tracks what's being transfered by the Apache web server in a SQL database (everything with a DBI/DBD driver). This allows to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). Apache::DBILogger will track the cookie from 'mod_usertrack' if it's there. After installation, follow the instructions in the synopsis and restart the server. The statistics are then available in the database. See the section VIEWING STATISTICS for more details. =head1 PREREQUISITES You need to have compiled mod_perl with the LogHandler hook in order to use this module. Additionally, the following modules are required: o DBI o Date::Format =head1 INSTALLATION To install this module, move into the directory where this file is located and type the following: perl Makefile.PL make make test make install This will install the module into the Perl library directory. Once installed, you will need to modify your web server's configuration file so it knows to use Apache::DBILogger during the logging phase. =head1 VIEWING STATISTICS Please see the bin/ directory in the distribution for a statistics script. Some funny examples on what you can do might include: =over 4 =item hit count and total bytes transfered from the virtual server www.company.com select count(id),sum(bytes) from requests where server="www.company.com" =item hit count and total bytes from all servers, ordered by number of hits select server,count(id) as hits,sum(bytes) from requests group by server order by hits desc =item count of hits from macintosh users select count(id) from requests where useragent like "%Mac%" =item hits and total bytes in the last 30 days select count(id),sum(bytes) from requests where server="www.company.com" and TO_DAYS(NOW()) - TO_DAYS(timeserved) <= 30 This is pretty unoptimal. It would be faster to calculate the dates in perl and write them in the sql query using f.x. Date::Format. =item hits and total bytes from www.company.com on mondays. select count(id),sum(bytes) from requests where server="www.company.com" and dayofweek(timeserved) = 2 =back It's often pretty interesting to view the referer info too. See your sql server documentation of more examples. I'm a happy mySQL user, so I would continue on http://www.tcx.se/Manual_chapter/manual_toc.html =head1 LOCKING ISSUES MySQL 'read locks' the table when you do a select. On a big table (like a large httpdlog) this might take a while, where your httpds can't insert new logentries, which will make them 'hang' until the select is done. One way to work around this is to create another table (f.x. requests_insert) and get the httpd's to insert to this table. Then run a script from crontab once in a while which does something like this: LOCK TABLES requests WRITE, requests_insert WRITE insert into requests select * from requests_insert delete from requests_insert UNLOCK TABLES You can use the moverows.pl script from the bin/ directory. Please note that this won't work if you have any unique id field! You'll get duplicates and your new rows won't be inserted, just deleted. Be careful. =head1 TRAPS I've experienced problems with 'Packets too large' when using Apache::DBI, mysql and DBD::mysql 2.00 (from the Msql-mysql 1.18x packages). The DBD::mysql module from Msql-mysql 1.19_17 seems to work fine with Apache::DBI. You might get problems with Apache 1.2.x. (Not supporting post_connection?) =head1 SUPPORT This module is supported via the mod_perl mailinglist (modperl@apache.org, subscribe by sending a mail to modperl-request@apache.org). I would like to know which databases this module have been tested on, so please mail me if you try it. The latest version can be found on your local CPAN mirror or at C =head1 AUTHOR Copyright (C) 1998, Ask Bjoern Hansen . All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO perl(1), mod_perl(3) =cut libapache-dbilogger-perl-0.93.orig/test.pl100644 1750 62 1226 6502130201 17510 0ustar mdormanstaff# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use Apache::DBILogger; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): libapache-dbilogger-perl-0.93.orig/README100644 1750 62 7603 6530300610 17065 0ustar mdormanstaffNAME Apache::DBILogger - Tracks what's being transferred in a DBI database SYNOPSIS # Place this in your Apache's httpd.conf file PerlLogHandler Apache::DBILogger PerlSetVar DBILogger_data_source DBI:mysql:httpdlog PerlSetVar DBILogger_username httpduser PerlSetVar DBILogger_password secret Create a database with a table named B like this: CREATE TABLE requests ( id mediumint(9) DEFAULT '0' NOT NULL auto_increment, server varchar(127) DEFAULT '' NOT NULL, bytes mediumint(9) DEFAULT '0' NOT NULL, user varchar(15), filename varchar(200), remotehost varchar(150), remoteip varchar(15) DEFAULT '' NOT NULL, status smallint(6) DEFAULT '0' NOT NULL, timeserved datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, urlpath varchar(200) DEFAULT '' NOT NULL, referer varchar(250), useragent varchar(250), PRIMARY KEY (id), KEY server_idx (server) ); Its recommended that you include use Apache::DBI; use DBI; use Apache::DBILogger; in your startup.pl script. Please read the Apache::DBI documentation for further information. DESCRIPTION This module tracks what's being transfered by the Apache web server in a SQL database (everything with a DBI/DBD driver). This allows to get statistics (of almost everything) without having to parse the log files (like the Apache::Traffic module, just in a "real" database, and with a lot more logged information). After installation, follow the instructions in the synopsis and restart the server. The statistics are then available in the database. See the section VIEWING STATISTICS for more details. PREREQUISITES You need to have compiled mod_perl with the LogHandler hook in order to use this module. Additionally, the following modules are required: o DBI o Date::Format INSTALLATION To install this module, move into the directory where this file is located and type the following: perl Makefile.PL make make test make install This will install the module into the Perl library directory. Once installed, you will need to modify your web server's configuration file so it knows to use Apache::DBILogger during the logging phase. VIEWING STATISTICS I haven't made any pretty scripts og web interfaces to the log- database yet, so you're on your own. :-) For a start try: hit count and total bytes transfered from the virtual server www.company.com `select count(id),sum(bytes) from requests where server="www.company.com"' hit count and total bytes from all servers, ordered by number of hits `select server,count(id) as hits,sum(bytes) from requests group by server order by hits desc' count of hits from macintosh users `select count(id) from requests where useragent like "%Mac%"' hits and total bytes in the last 30 days `select count(id),sum(bytes) from requests where server="www.company.com" and TO_DAYS(NOW()) - TO_DAYS(timeserved) <= 30' hits and total bytes from www.company.com on mondays. `select count(id),sum(bytes) from requests where server="www.company.com" and dayofweek(timeserved) = 2' See your sql server documentation of more examples. I'm a happy mySQL user, so I would continue on http://www.tcx.se/Manual_chapter/manual_toc.html SUPPORT This module is supported via the mod_perl mailinglist (modperl@listproc.itribe.net). I would like to know which databases this module have been tested on, so please mail me if you try it. AUTHOR Copyright (C) 1998, Ask Bjoern Hansen . All rights reserved. This module is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO perl(1), mod_perl(3)