#! /bin/sh CACHEDIR=/var/spool/webalizer TEMPLATE=/usr/local/etc/webalizer.conf.template OUTPUTDIR=/usr/local/www/data/webalizer/ ACCESSLOG=/var/log/httpd-access.log WEBALIZER=/usr/local/bin/webalizer cleanup() { rm -f TMPLOG } mkdir -p $CACHEDIR/conf TMPLOG=`mktemp /tmp/webalizer.XXXXX` || exit 1 trap cleanup 1 2 15 list_domains() { grep '^[^#]*ServerName' /usr/local/etc/apache2/httpd.conf /usr/local/etc/apache2/Includes/*|sed 's/^.*ServerName[ ]*\(.*\)$/\1/' } list_domains | while read domain ; do sed -e "s#%OUTPUTDIR%#$OUTPUTDIR/$domain#;s/%HOSTNAME%/$domain/" < $TEMPLATE > $CACHEDIR/conf/$domain.conf mkdir -p $OUTPUTDIR/$domain # in the first run, webalizer populates the DNS cache grep -h " $domain$" $ACCESSLOG | tee $TMPLOG | $WEBALIZER -D $CACHEDIR/dnscache -N 20 -c $CACHEDIR/conf/$domain.conf - # second run: generate the actual stats $WEBALIZER -c $CACHEDIR/conf/$domain.conf -N 0 -D $CACHEDIR/dnscache $TMPLOG 2>/dev/null done