Recently I’ve been implementing awstats, to obtain some statistics and information about the usage of some the services for work. Its been quite challenging as you may have noticed from earlier posts to gather the log files in a single location where they can all be analyzed, but it has been accomplished.

As soon as I obtain my first day of statistics, I found loads of useful information but required something a bit more specific. I was requested to investigate the use of web browsers, specifically for tools that make use of our “WebDav” system. So I needed to add a browser(s) to the list generated by awstats. with no time to put in a request and wait for an update from the developers at awstats (I really didn’t think of contacting them), I decided to get my hands a little dirty and try to add the WebDrive tool in the list of browsers.

My First attempt was to modify the ./lib/browsers.pm file. Simple enough as describes by many sources in the Internet, I added a few lines of code:

  • In the @BrowsersSearchIDOrder Array I added an ID for ‘webdrive’ in a new line. Be sure to add a comma to follow the structure of the array and avoid errors.
  • In the %BrowsersHashIDLib Hash I added an ID/Name reference like so; ‘webdrive’,’WebDrive’. Again be careful with the commas!.
  • A .png icon file was added ./wwwroot/icon/browser/webdrive.png to make it a little fancy. Of course a reference is needed to be added in the %BrowsersHashIcon Hash that reference the browser Id and the file, like so ‘webdrive’,’webdrive’.

And that was it, next time the awstats ‘cron’ job run, the browser was in the Browsers > Versions area. That was simple and now I had some information to show to my boss if he needed it.

Of course that was not the end, later I noticed I had multiple versions of the same “browser” and like Firefox, IE, or Safari I wanted to see the different versions listed with their individual stats, not just a single item with all the statistics, but how?. Well here is where I needed to get my hands a little dirty. (The information below requires modifying your awstats.pl file version 6.95 at the time of this post, please make a backup of the file and don’t blame me for breaking it, you are fully responsible of any changes you make!)

So I open the ./wwwroot/cgi-bin/awstats.pl file (Note: file location may change based on OS and installation) and modify a few things to get my different versions of the browser listed:

  • In line 400 you will find the %BrowsersFamily hash which contains a list of all browser families, here I added a new line for my web browser as follows 'webdrive' => 9. Please be sure to add the commas where required.
  • In line 10567 you will find “# Define precompiled regex”, here the developers create multiple regular expressions to check and grab the browser information/version. Using the “konqueror” regular expression I added my own right below it:
    my $regverwebdrive    = qr/WebDrive\s([\d\.]*)/i;               # WebDrive
    This will basically check for the string “WebDrive 8.0.1.2″ or similar, but I was not done yet.
  • further down, in line 12096 (or near it), is where I found the “Analyze: Browser” starts. Here I added a statement to check for “WebDrive” just before “# Other known Browsers” (near line 12180).
    # WebDrive Version ...? Hopefully this works :)
    elsif ($UserAgent =~ /$regverwebdrive/o ) {
    $_browser_h{"webdrive$1"}++;
    $TmpBrowser{$UserAgent} = "webdrive$1";
    }

    Ideally the operation checks the string against my regular expression and if we have a match we first add a counter to the $_browser_h{“webdrive$1″} variable, then we also add the browser and version to the $TmpBrowser{$UserAgent} variable.

Thats it!!, let awstats run and you will find the browser and different versions listed in your awstats analysis.

I really hope this information gives you and idea of what you need to do and good luck!.

UPDATE  (May-10/2011): So I made an update of the Awstats Version 6.95 to 7.0 and of course I wanted my changes to go over. So Here are a few tips:

  • %BrowserFamily is now located in the ./lib/browsers.pm folder.
  • The “Define precompile regex” are now located in line 17454.
  • The “Analyze: Browser” is now located in line 19001.
Tagged with:
 

Processing.js

Drag&Drop Design

Drag&Drop Design

In voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur occaecat cupidatat non proident, in culpas officia deserunt.

Processing.js Easing