NAME

httptraffic.pl - Merge webalizer .hist files into a MySQL database and generate reports


SYNOPSIS

httptraffic.pl [-HqvV] [-h hostname] [-d database] [-u user] [-p password] [-t tablename] [-m month] [-y year] basedirectory

httptraffic.pl [-HqvV] [-h hostname] [-d database] [-u user] [-p password] [-t tablename] [-m month] [-y year] [-r] domainname


DESCRIPTION

httptraffic.pl overcomes a missing feature of webalizer: monitoring overall statistics for longer than only the last 12 months. It uses a MySQL database to save and/or analyze the statistics generated by the webalizer program.

httptraffic.pl has two modes of operation: In database update mode, it gathers data from history files generated by webalizer and merges them into the database, and in report generation mode, it generates reports from the database.

Database update

In database update mode (the default), httptraffic.pl parses the monthly history files generated by the webalizer program and merges the parsed data into a MySQL database. The input is taken from the specified basedirectory which is supposed to contain one directory per domain, in which the webalizer output can be found.

Example: If you specify /var/wwwstats/ as the basedirectory, the following history files will be read:

   /var/wwwstats/somedomain.org/webalizer.hist
   /var/wwwstats/outer.galaxy.net/webalizer.hist
   /var/wwwstats/test.com/webalizer.hist
   ...

httptraffic.pl does not erase records for months older than one year, unlike webalizer does. In real life, this script can be used to keep monthly records of access statistics generated by the webalizer program and subsequently use it to generate reports. If webalizer is run via the cron facility, it is most likely that httptraffic.pl also should be run via cron.

Report generation

The report generation mode is entered by specifying the -r option. The report can be done for a specific year and/or month and/or for all domains or only a specific domain. By default, it generates cross-domain totals. If you want to have a report for a specific domain, simply give the domain name as last parameter.


OPTIONS

-d, --database database
Specify the MySQL database.

-h, --host hostname
Specify the MySQL hostname.

-H, --help
Print out this documentation (which is done simply by feeding the script to perldoc -t).

-m, --month month
Specify the month for the report to be generated.

-p, --password password
Specify the MySQL password.

-q, --quiet
Do not print anything. Be quiet.

-r, --report
Generate a report. Do not update the database.

-t, --table tablename
Specify the name of the SQL table. Default: 'httptraffic'.

-u, --user username
Specify the MySQL username.

-v, --version
Print the version of multilog-stamptail and exit.

-V, --verbose
Print more information during execution.

-y, --year year
Specify the year for the report to be generated.


EXAMPLES

   httptraffic.pl --verbose /var/wwwstats/

will update the database using the webalizer.hist files found within subdirectories of the directory /var/wwwstats/

   httptraffic.pl  -r -y 2005

will generate a cross-domain traffic report for the year 2005

   httptraffic.pl  -r -y 2005 example.com

will generate a monthly traffic report for the domain example.com in the year 2005


SQL table

This script needs one SQL table with the following structure (in MySQL syntax):

   CREATE TABLE `httptraffic` (
     `domain` varchar(255) NOT NULL default '0',
     `month` tinyint(4) NOT NULL default '0',
     `year` int(11) NOT NULL default '0',
     `hits` int(11) NOT NULL default '0',
     `files` int(11) NOT NULL default '0',
     `sites` int(11) NOT NULL default '0',
     `kbytes` int(11) NOT NULL default '0',
     `firstday` tinyint(4) NOT NULL default '0',
     `lastday` tinyint(4) NOT NULL default '0',
     `pages` int(11) NOT NULL default '0',
     `visits` int(11) NOT NULL default '0',
     `mtime` timestamp(14) NOT NULL,
     PRIMARY KEY  (`domain`,`month`,`year`)
   ) TYPE=MyISAM;


SEE ALSO

See http://www.mrunix.net/webalizer/ for information on the webalizer program.

The current version of this program is available from its web page at http://spurious.biz/~pkremer/projects/scripting/#perl.


BUGS

Report bugs to pkremer [at] spurious [dot] biz


COPYRIGHT AND LICENSE

Copyright 2005, Paul Kremer.

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.


AUTHORS

Paul Kremer <pkremer [at] spurious [dot] biz>