HOWTO: import old logs in AWStats
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/awstats.pl -update -config=config.site.com -LogFile=/tmp/tmplog')
If you have problems, comment this post!



Andrea Corbellini 11:09 pm on September 19, 2011 Permalink |
Hi! AWStats ships with a tool (logresolvemerge.pl) which does exactly the same thing. Also, I think the best way to use the script is not via a temporary file, but specifying something like this in the configuration:
LogFile=”…/awstats-7.0/tools/logresolvemerge.pl …/access.log* |”
The pipe symbol tells AWStats to read logs from the output of the command instead of from a file.
[This is with AWStats 7.0, I don't know about older versions]
diegor 10:51 am on September 20, 2011 Permalink |
Thanks Andrea for your suggestion! When I used AWStats, there wasn’t any tool to do that, so I created my own