Skip to main content
Wazo, LLC Company Logo

Wazo, LLC Network Administrators Blog

Go Search
Home
  

Wazo, LLC Network Administrators Blog > Posts > Combining/Parsing JBoss Weblogs using Stone Steps Webalizer on Windows
Combining/Parsing JBoss Weblogs using Stone Steps Webalizer on Windows
Recently I was asked by a client who has a mixed Windows/Linux infrastructure if there were any solutions for providing basic web statistics. Naturally The Webalizer by Mr. Unix came to mind. It's free, simple and has low resource usage. I've recently been using an updated version of The Webalizer by Stone Steps called, appropriately enough, Stone Steps Webalizer - those crazy Canadians and their wild imaginations. Feel free to click the link to see a summary of what the wonderful folks at Stone Steps have added to enhance The Webalizer.
 
The issue that immediately came to mind, was how to output a logfile from JBoss in a format that The Webalizer could parse and how to combine the log files from each of our load balanced JBoss servers into one file that the Webalizer can process.
 
So, let's get JBoss to output a logfile in the Apache Combined, or rather, the Combined Log File format, because we want to know information like the browser in use (User Agent) and Referrer (where they came from).
 

 
JBoss makes this pretty simple, open the following file in your favorite text editor and add the line I've noted below.
 
 /server/default /deploy/jbossweb-tomcat55.sar/server.xml
  1. Find the org.apache.catalina.authenticator.SingleSignOn Valve section and add a new Valve immediately above it that contains the following information:
    1. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="${jboss.server.home.dir}/log" prefix="access-server##." suffix=".log" pattern="combined" resolveHosts="false" />
  2. This will create a file in your JBoss home directory/log subfolder, called access-server##.log in the Apache Combinded Log File format. Make sure to replace the ## symbols with a unique identifier for each server.
  3. Perform a restart of your JBoss server to complete the process.
  4. Done!


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:

  1. #!/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:

    1. @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:

    1. GraphFontNormal     c:\webalizer\lucon.ttf
    2. GraphFontBold          c:\webalizer\tahomabd.ttf

 

Happy Stats Processing!


 

 

Comments

There are no comments yet for this post.