Example IIS Site Summary with Log Parser and Perl

Added 7/15/2011 9:26:38 PM and updated 7/15/2011 9:29:37 PM

While Log Parser works great with single queries, you can also create mini-Web sites combining a number of scripts.

Chevis Nelson was kind enough to share a Perl script that uses Log Parser to generate Web site statistics by combining a number of scripts and saving the output to HTML files.

The following article will get your environment setup, if needed, and introduce you to his script.

Getting started

The script uses Perl to run. If you do not have Perl installed on your machine yet, I recommend ActivePerl from ActiveState, of which there is a free, Community Edition, available.

You’ll also want to have Log Parser set in your environment variables, or a copy of LogParser.exe in the same directory as the above download’s contents.

Finally, you’ll need to be able to create charts via Log Parser. See How to enable Log Parser chart export with Office 2007/2010 if you’re not on Office 2003 or earlier.

Download Chevis Nelson’s IIS Site Summary (zip).

Updating the script

Next you’ll want to update the script based upon your own particular environment.

The first file to change is IISOverview.pl.

First verify that the first line is set to the path of your Perl install. On my machine, this was for example: c:/perl64/bin

Line 11 contains the path to input_parameters.txt, which is included in the download, and will be covered momentarily.

Finally line 18 contains the path to the directory the output should be written to. In Chevis’ example you can see that he was writting to a directory that could then be served by IIS.

The second file to change is input_parameters.txt.

This file contains a comma-delimited listing of three items.

The first two items are used to determine which directories the output should be saved to.

The third item is the path to the log file(s) that should be parsed. Note that you can absolutely use the * wildcard when using your path - for example LogParserPlus,TestUser,\\server1\projects\Logs\Server2008\W3SVC7\*ex1101*.log - but is best run against a single day’s worth of data.

The third and final file to change is the Summary-Errors.tpl file.

On line 47 is the path to the directory you extacted the contents of the download to. You could optionally copy the httpstatus.html file to a single location on your computer/server, and change the path to that.

Running the script

Now that the script has been updated for your environment you can run the script. If using ActivePerl you should just be able to run the IISOverview.pl file, either directly or via the command line (if you wish to view errors and warnings).

Once the script has run the directory specified by your input_parameters.txt file will be created and populated with the HTML reports.

Sample output

A sample output of this script can be viewed for this very site (albeit from January 2011, so things have changed). As you can see the script generates charts as well as HTML files with the statistical information.

Again, a special thanks to Chevis L. Nelson for providing this sample script and queries.

Script provided by Chevis L. Nelson and article written by James Skemp.

Back to List


blog comments powered by Disqus