AWStats for a load balanced environment

A couple of FAQs from the official AWStats doc addresses the question: How do I use AWStats in a load-balanced environment?

FAQs are here and here.

So this turned out to be fairly easy to implement.

Going up to same shared storage I put my static web files on (let’s call it “/nas1”), I created a “logs/n1” and “logs/n2” directory to hold the access logs from my two load-balanced web servers. The Apache config looked something like this:

Web Server 1:

CustomLog /nas1/logs/n1/ combined

Web Server 2:

CustomLog /nas1/logs/n2/ combined

[Note that AWStats really prefers using the “combined” log format, which I have to modify slightly for my environment because of our reliance on x-forwarded-for to get the real addresses of clients passing through the load balancer.]

Then I modified the awstats conf file for the site ( under /etc/awstats to invoke the tool for aggregating these logs on the fly whenever awstats does an update:

LogFile="/usr/share/awstats/tools/ /nas1/logs/n1/ /nas1/logs/n2/ |"

That’s all on one line in real life.

Once everything was in place (and I had some logged activity to analyze), I did an update to the awstats database to check for errors:

/usr/share/awstats/wwwroot/cgi-bin/ \ -update

The output should have shown that the script processed the piped command against both log files. Instead, in my case a small typo in the log file path caused to keep throwing an error until I fixed it. With the error fixed the db updated and I now had awstats’s analysis of the aggregated log data.

This entry was posted in System Administration, Systems Analysis, Web on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).