Weblog entry #11 for lee

Static output from awstats for multiple sites
Posted by lee on Mon 20 Feb 2006 at 16:16
Tags: none.

I'm setting up awstats to process multiple domains, and outputting to static html files. A previous article concerning generating website statistics provides instruction on outputting static reports, and suggests modifying awstats-update for multiple configs.

So in order to run monthly reports, available from a URL such as "http://stats.example.com/stats/example.org/2005/12/awstats.example.org.html", I have created a script to run as a monthly cron job.

#!/bin/sh

## specific months can be specified on command line, eg " 2005 01"

WEBDIR=/var/www/stats
#WEBDIR=/srv/web/stats.example.com/docs/stats

if [ -n "$1" ]
  then YEAR=$1
  else YEAR=`date +%Y --date="1 month ago"`
fi
if [ -n "$2" ]
  then MONTH=$2
  else MONTH=`date +%m --date="1 month ago"`
fi

for cfg in `find /etc/awstats -name 'awstats.*.conf' -printf '%f\n' | sed 's/^awstats\.\(.*\)\.conf/\1/'`; do
        mkdir -p $WEBDIR/$cfg/$YEAR/$MONTH
        /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl \
          -awstatsprog=/usr/lib/cgi-bin/awstats.pl \
          -year=$YEAR -month=$MONTH \
          -dir=$WEBDIR/$cfg/$YEAR/$MONTH/ \ 
          -config=$cfg > /dev/null
done

 

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search