Parse old gzipped apache(vhost_combined) logs with awstats

Parse all logs to new log-file in chronological order.

zgrep ^blog.seljebu.no `find -name "other_vhosts_access.log.[0-9]*.gz" | sort -n -t . -k 4 -r` | sed 's/./other_vhosts_access.log.[0-9]*.gz:blog.seljebu.no:80 //g' > blog.seljebu.no/old.log
grep ^blog.seljebu.no other_vhosts_access.log.1 | sed 's/blog.seljebu.no:80 //g' >> blog.seljebu.no/old.log
grep ^blog.seljebu.no other_vhosts_access.log | sed 's/blog.seljebu.no:80 //g' >> blog.seljebu.no/old.log

Make config-file for awstats.

#/etc/awstats/awstats.blog.seljebu.no.conf
LogFile="/var/log/apache2/blog.seljebu.no/old.log"
LogFormat=1
SiteDomain="blog.seljebu.no"
HostAliases="blog.seljebu.no"
DirData=/var/lib/awstats

Delete awstats database and update awstats. If you get a lot of corrupted/dropped records, you could use -showcorrupted/-showdropped.

rm /var/lib/awstats/awstats*blog.seljebu.no*
/usr/lib/cgi-bin/awstats.pl -config=blog.seljebu.no -update

Make individual log-files for virtualhosts.


        Servername blog.seljebu.no
        CustomLog /var/log/apache2/blog.seljebu.no/access.log combined
        ...

Add new log files to logrotate.

#/etc/logrotate.d/apache2 
/var/log/apache2/*/*.log /var/log/apache2/*.log {
        weekly
        ...
}

Update awstats config-file.

#/etc/awstats/awstats.blog.seljebu.no.conf
LogFile="/var/log/apache2/blog.seljebu.no/access.log"
...

Add to cron.

#/etc/cron.d/awstats
*/10 * * * * www-data /usr/lib/cgi-bin/awstats.pl -config=blog.seljebu.no -update >/dev/null