Apache-DBILogger
view release on metacpan or search on metacpan
bin/webstat_mail.pl view on Meta::CPAN
#!/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;
bin/webstat_mail.pl view on Meta::CPAN
$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;
( run in 0.235 second using v1.01-cache-2.11-cpan-4d50c553e7e )