Project Management

Get log statistics with AWStats

AWStats is a free Perl program that you can run for real-time log analysis via a CGI script. Here is how to use AWStats on your network.

If you're interested in analyzing log files, a few Web log file analyzers are available. The most widely known programs include Analog and The Webalizer.

However, another tool that contains a vast array of information is AWStats. AWStats is a free Perl program that you can run for real-time log analysis via a CGI script. In addition, you can run it periodically to create static Web pages.

The installation and configuration of this tool is quite simple. The example config file doesn't require much modification. In fact, the only keywords that you really need to modify are the LogFile, SiteDomain, HostAlias, and DirData keywords. After you've created a new file from the copy (e.g., /etc/awstats/awstats.myhost.com.conf) and made these changes, you're ready to begin creating reports.

If you're monitoring a number of sites, you can create a configuration file for each site and write a cron job that runs every day and makes static pages. Let's say that you've set up a directory that will have domains as subdirectories (e.g., /srv/www/mysite.com/html/awstats/mysite.com). For this example, you would view the statistics by going to http://mysite.com/awstats/mysite.com/.

If you're running three Web sites (e.g., mysite.com, yoursite.com, and hersite.com), your script to process the statistics for each would look something like the following:

#!/bin/sh

AWSTATS="/usr/local/awstats/awstats.pl"
AWBUILD="/usr/local/awstats/awstats_buildstaticpages.pl"

for i in mysite.com yoursite.com hersite.com;
do
  perl $AWBUILD -config=$i -update -awstatsprog=$AWSTATS \
    -dir=/srv/www/mysite.com/html/awstats/$i
done

Set this script to run every night, and you'll be able to get Web site statistics on all of the Web sites you host updated daily. AWStats writes the "root" page as awstats.mysite.com.html, so it's a good idea to make a symlink of the file that points to index.html to make it even easier to view.

To download this handy tool, visit the AWStats Official Web site.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!

About

Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.

0 comments

Editor's Picks