HOWTO: import old logs in AWStats

less than 1 minute read

AWStats is a great software to analyse Apache logs for having statistics about your sites. Unfortunately it doesn’t offer a tool to import old logs into AWStats. For that I’ve created a small python script to do this. Here you go:

import commands
raw_data = commands.getoutput('ls -rt /var/log/apache2/wespot-access80.log.*.gz')
logs = raw_data.splitlines()
for log in logs:
commands.getoutput('zcat %s > /tmp/tmplog' % log)
commands.getoutput('/usr/lib/cgi-bin/ -update -LogFile=/tmp/tmplog')

If you have problems, comment this post! :)

Leave a comment