I was recently assigned the task of removing [insert name of popular commercial web statistics package here] on a number of Windows virtual servers. Without getting into the requisite culture war over which open-source statistics package is better, after some discussion among my engineers we settled on Webalizer. It runs pretty well, it’s multi-platform, and it looks pretty nice. The look is somewhat customizable as well.
We had a couple of ancient Windows web servers already running Webalizer, which was a factor in our decision. However, these servers had a set of individual batch files which did Webalizer’s dirty work. I thought that was inefficient and demanded too much overhead when adding/removing sites. After all, we’re talking about a virtual hosting environment, with hundreds of sites on a server, and sites coming and going every week.
I had stumbled upon Microsoft’s ADSI Utilities a while back, when researching a method of quickly reporting a list of sites on a server. We had already been using a subset of the ADSI utilities for provisioning new sites, but had not explored the potential of using the full set.
I wanted a system that would (1) run webalizer on every site on the server; (2) create the stats directory in a predetermined location, if necessary; (3) allow for customer webalizer configuration files; (4) revert to a default webalizer configuration file if no custom file is provided; and (5) adjust itself continuously to site creations, deletions and modifications. I also wanted to eliminate as much manual work as possible.
The system we finally settled on is a set of scripts. The first script, makelogbatch.vbs, runs via cscript, and creates the actual webalizer batch file which runs the requisite rconvlog and webalizer programs.
An outline of makelogbatch.vbs:
- Cycle through all sites: for each site,
- Check to see if site is running. If running,
- Detect site content directory
- Detect log directory and site number
- Create lines to run rconvlog on recent logs
- Create lines to run webalizer on converted logs
- Create lines to delete converted logs after import
- Pipe these lines to the logbatch.bat file
The logbatch.bat file ends up being a dynamically generated site-by-site execution of log conversion and webalizer for all running sites. I run both daily.
Since I have a good number of these servers, I thought it would also be helpful to centralize the deployment of these files and include a “check for updates” function. I added this function as a file (getconf.ftp, a standard MS-DOS scripted FTP session) and a call to execute that session, written into logbatch.bat by makelogbatch.vbs, prior to cycling through the sites.
We also decided to delete old log files by policy, so I needed to download the delold utility and incorporate that into our system by adding additional lines to logbatch.bat within the site-cycle section of makelogbatch.bat.
As you’ll see when you read the file, we ended up adding additional functionality. It’s hard to avoid going overboard when you have a centralized, powerful tool like this.
Our final files are on the next page: