Smartlab Software logo

AWStats: Update the Statistics Database

AWStats logo The usable log file's information is extracted and put in the AWStats database.

Steps

  1. Acquire AWStats, other programs, and pertinent information
  2. Install AWStats on the 1and1 shared server
  3. Install AWStats on your computer
  4. Set up the AWStats config file
  5. Create a usable log file
  6. Create/update the AWStats database
  7. Create a traffic web page
  8. Create report batch files
  9. Analyze the traffic page
  10. Tasks

Extending AWStats

  1. Extras
  2. Geographic Plug-ins
  3. How To

Help

  1. Glossary
  2. FAQ
  3. Pages not found FAQ
  4. Stop Referrer Spam

Update the AWStats Database

The awstats database, which is really a collection of text files, needs to be created/updated before any statistics can be viewed. We have made the AWStats database in the statdata directory. When a database is updated AWStats creates a backup with the .bak extension. The database directory is specified in the config file's DirData entry.

Regardless of where invoked, the update process reads the log file (specified in config's LogFile entry), parses it, and creates/updates a text file in DirData. These files, awstatsXX.myname.txt are AWStats' database.

Once a monthly database file has been updated, it does not have to be updated again; it can be viewed in the main AWStats screen by selecting the corresponding Reported period month and year.

 On your computer

The mytools batch files use awstats_buildstaticpages.pl to create traffic reports. One of the options is -update which will update the database before creating the reports. In our case a txt file in the statdata directory is updated or created.

On the server

Enter the URL to your awstats.pl program and the name of the config you want to use.

http://www.mydomain.com/awstats/wwwroot/cgi-bin/awstats.pl?config=sls

A generic AWStats screen should show up. Set the reported period to the month and year. Click OK. This sets the month and year in the 'update now' link.

Click the 'update now' button at the top. If there is no update now link then check AllowToUpdateStatsFromBrowser in your config file. It should be set to 1.

Once the update occurs you will be able to see the information in the AWStats screen. It may take a while to update.

Advanced

from the command line

This works only if you have SSH access or you do it locally.

# perl /home/jsmith/awstats/wwwroot/cgi-bin/awstats.pl -config=mysite -update -showcorrupted

from cron

Only works if you have access to cron.

cron jobs for few config files

In order automatically update AWStats, you will need to create a cron job. As discussed before, I suggest updating on a daily basis:

$ crontab -e

VIM opens up. Hit "i" and enter the following line:

15 4 * * * perl $HOME/awstats/cgi-bin/awstats.pl -config=yourself -update

This cron job will update AWStats at 4.15am on a daily basis. "-config="yourself"" refers to your config file (for your dog add another cronjob).

Make sure there is a trailing empty line at the end of your crontab file (after your last command-line). Then hit "[Escape]" to leave the editing mode and type ":x" to save the file and close VIM.

cron job for many config files

If you have many config files, adding lots of cron jobs may not be very comfortable. In that case you might want to make use of "awstats_updateall.pl", a tool that comes with AWStats, by choosing this alternative cron job (without linebreaks):

15 4 * * * perl $HOME/awstats/tools/awstats_updateall.pl now -awstatsprog=$HOME/awstats/cgi-bin/awstats.pl -configdir=$HOME/awstats/cgi-bin/

Using "awstats_updateall.pl" will call "awstats.pl" and run an update for all config-files to be found in the specified directory (awstats/cgi-bin). Since in this case "awstats.pl" is being executed you need to make sure that permissions are set accordingly:

$ chmod 504 awstats/cgi-bin/awstats.pl

This will allow yourself and thus your cronjob to execute "awstats.pl".

Next: Create Traffic Report

Related resources

Build Static Pages - doc on awstats_buildstaticpages.pl