Now, we've got a log file that Webalizer will parse, so how do we combine multiple log files into a single logfile for Webalizer to parse? On Windows, this is pretty simple. I'm sure anyone with basic shell scripting experience could whip something up in a few seconds to do the same thing on Linux as well.
The first step is to get the log files over to the Windows machine for processing. I do this with an hourly cronjob that simply copies the files to a Windows (CIFS) share I have mapped across our management subnet. This could also be accomplished by using FTP, NFS, or SCP. That is beyond the scope of this article, so I'll leave that portion up to you. For reference, this is how simple the cronjob script is that runs on each of my JBoss servers:
- #!/bin/sh
cp /jboss-4.0.5.GA/server/default/log/access-server* /mnt/win/logs
Yep, two lines, very simple eh?
Ok, so now we've gotten the files over to our Windows machine and they are ready for parsing. I am also not going to detail the steps for configuring Webalizer, as you should have a functional copy before attempting these steps. (Stone Steps Webalizer FAQ)
I simply created a batch file that does a Windows copy, but instructs Windows to combine the files. We don't need to worry about sorting, because Webalizer will use the date/time stamp on each entry to calculate the stats correctly!
So, click on Start -> Run and type notepad combine-logfiles-for-webalizer and run.bat. The simply add the following entry updating for your environment as necessary:
- @echo off
c:
cd\webalizer\logs
copy access-server01*.log /a +access-server02*.log /a web-access.log /a
cd ..
webalizer.exe webalizer.conf
cd logs
del /q web-access.log
del /q access-server01*.log
del /q access-server02*.log
Just make sure in your webalizer,conf file, you've told it to look for web-access.log, then run webalizer or webalizer -c webalizer.conf and go have a look at your beautiful new, combined stats!
After you verify everything is working correctly, create a Windows Scheduled Task to run combine-logfiles-for-webalizer and run.bat once an hour or so to keep your stats up to date. I personally have my JBoss cron job configure to run at 30 minutes past the hour and then I kick off Webalizer right on the hour to combine the log files and update the stats.
Note: If your stats output isn't displaying correctly, make sure a copy of the webalizer.css file lives in the output directory or webroot. In addition, if webalizer is running on Windows, copy lucon.ttf and tahomabd.ttf to the webalizer folder and add the following two lines to your Webalizer.conf file:
- GraphFontNormal c:\webalizer\lucon.ttf
- GraphFontBold c:\webalizer\tahomabd.ttf
Happy Stats Processing!