This HOW-TO written by
Peter Rose.
Converted to HTML and Step Three added by
Stephen Turner.
One of the great things about Analog is that it can easily be used to offer different customised output to multiple virtual hosts on the same server.
This is an obvious asset if you host several domains on your server and want to offer all your customers the benefit of daily/weekly/monthly Analog stats, but not all of them require the same level of reporting or the same 'look'.
This real-world example is based on Apache 1.3.12 running on RedHat Linux 6.1, but should be applicable to any Unix-like platform. Steps Two and Three, and the general ideas, should be helpful on Windows NT and other operating systems, but for the details you'll have to ask someone else :-)
Here's an example from my httpd.conf:
<VirtualHost 212.87.82.24> ServerName www.ontiles.com SSLDisable DocumentRoot /home/httpd/html/tileshop ServerAdmin [email protected] CustomLog logs/ontiles-referer_log referer TransferLog logs/ontiles.com-access_log </VirtualHost> <VirtualHost 212.87.82.24> ServerName www.nuw-maas.co.uk SSLDisable DocumentRoot /home/httpd/html/nuwmaas ServerAdmin [email protected] TransferLog logs/nuw-maas-access_log </VirtualHost>
Here you can see there are 2 virtual hosts with different logging requirements:
ontiles.com wants to get a referer report as well as the regular access statistics, whereas nuw-maas.co.uk only needs the basic access stats.
For ontiles.com, we have a file called (with stunning originality) ontilesanalog.cfg. The relevant parts from this are as follows:
LOGFILE /etc/httpd/logs/ontiles.com-access_log LOGFORMAT REFERRER LOGFILE /etc/httpd/logs/ontiles-referer_log OUTFILE /home/httpd/html/cyberscreen/stats/ontiles_stats.html HOSTNAME "ONTILES.COM" HOSTURL "http://www.ontiles.com/" IMAGEDIR "http://www.cyberscreen.com/images/" LOGO "ontileslogo.jpg" STYLESHEET ontilesanalogstyle.cssNote the order in which the LOGFILE and LOGFORMAT commands appear - if the LOGFORMAT REFERRER is not before the LOGFILE /etc/httpd/logs/ontiles-referer_log, it won't work! You can see also that we're giving the reports for this domain their own logo at the top of the page and are using a stylesheet that will match that of their website. Not essential, but you can't beat the finishing touches :-)
Now here's the same section for the analog.cfg file for the other virtual host - which, yes, you've guessed it, is called nuw-maasanalog.cfg.
LOGFILE /etc/httpd/logs/nuw-maas-access_log OUTFILE /home/httpd/html/cyberscreen/stats/nuw-maas_stats.html HOSTNAME "WWW.NUW-MAAS.CO.UK" HOSTURL "http://www.nuw-maas.co.uk/" IMAGEDIR "http://www.cyberscreen.com/images/" LOGO "nuw-maaslogo.jpg" STYLESHEET nuw-maassanalogstyle.cssSo by this time, you get the idea. This domain don't need the referrer report, but they would like their own groovy logo and stylesheet applied to the output. You can, of course, take the opportunity within each domain's analog.cfg file to tweak the output appearance, request floors and so on according to each host's requirements.
LOGFILE /etc/httpd/logs/ontiles.com-access_log http://www.ontiles.com LOGFILE /etc/httpd/logs/nuw-maas-access_log http://www.nuw-maas.co.uk OUTFILE /home/httpd/html/cyberscreen/stats/overall_stats.html HOSTNAME "Cyberscreen" IMAGEDIR "http://www.cyberscreen.com/images/" SUBDIR http://*Notice the SUBDIR command at the end. This enables us to see the amount of traffic for each virtual host in the Directory Report. This information is not in the Virtual Host Report, because the virtual host name is just part of the filename, not an item on its own.
When we run this report, analog will give us a "possible double counting" warning. This just means that the dates for the logfiles overlap, and it's nothing to worry about because all the logfiles are from separate virtual hosts.
#!/bin/sh cd /etc/httpd/analog4.0 ./analog -G +gontilesanalog.cfg ./analog -G +gnuwmaasanalog.cfg ./analog -G +gall.cfgObviously, the first line reflects the location of my analog - yours may well be somewhere else. And of course, if you've put Analog in your $PATH, you won't need the ./ at the beginning of each line. What we're doing here is simply running Analog twice using a different config file each time. I won't say you can do this ad infinitum, but I'm up to 20 virtual hosts and Analog processes the whole lot in seconds. The important switches are the -G , which tells Analog not to use the default config file, and the +g in front of each cfg filename, which tells Analog to use that particular config file. No, you don't leave a space before the filename.
If you include the -G, the individual config files replace the global analog.cfg. If you don't include -G, then each domain will get the global analog.cfg plus its own analog.cfg.
And that's it! You now have Analog reports automatically generated and customised for all your virtual hosts.