IIS 6

1 Overview For IIS6

You need two things,
- Proper IIS Log Format
- The submission script and associated files

1.1 IIS Log Format Settings

The hard part seems to be getting the log settings correct. The default {link:MS W3C Log Format|http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6ac46bf0-815f-4983-b256-6422a8d817e1.mspx?mfr=true} setting is not appropriate 

Bring up the properties of the "Web Sites" folder icon, select the "Web Site" tab and find the "Active log format field". Make sure "W3C Extended Log File Format" is selected and hit the properties button right next to it. In the properties box that just popped up, hit the "Advanced" tab and select the below fields (solid means select it and empty means de-select it)
- Date ( date )
- Time ( time )
-- Client IP Address ( c-ip )
-- User Name ( cs-username )
** Service Name
** Server Name
** Server IP Address
** Server Port
-- Method ( cs-method )
-- URI Stem ( cs-uri-stem )
-- URI Query ( cs-uri-query )
-- Protocol Status ( sc-status )
** Protocol Substatus
** Win32 Status
-- Bytes Sent ( sc-bytes )
** Bytes Received
** Time Taken
-- Protocol Version (cs-version)
** Host
-- User Agent ( cs(user-agent) )
** Cookie
-- Referer

This results in this header in the IIS Log

#Fields: date time cs-method cs-uri-stem cs-uri-query cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes

And the corresponding entry in the conf file on the server would be

LogFormat="date time cs-method cs-uri-stem cs-uri-query cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes"


1.1 The Submission Script

The Next part is the scheduled script that sends the logs to the stats server.
- Generate a key using puttygen, and email us the public key
- Customize the batch file and add to the windows scheduler

The lastest PuttyGen can be had from:
- http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe
When you generate the key, copy the public key from the top part directly into an email. Failing that save it somewhere handy. You'll need to send us this via email. Save your private key somewhere handy as well, as you'll need it for the batch file to run.

The example batch file assumes that you have left things in the default locations. It also assume you put the private key in the same directory as it, name the private key the same as your host, and that windows scheduler will "start-in" this folder when it runs the task. Notice on the 4th line, it calls the __pscp__ executable. You'll want to put it in the same folder. Download it here
- http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe

{code:none}
@ECHO OFF
set HOST=workforce
set DIR="C:\Program Files\Apache Software Foundation\Apache2.2\logs"
set WORKDIR="E:\OIT\Scripts\LogSend"
set FILES=access*.log
set DEST=stats@stats.cats.ohiou.edu:data/logs/%HOST%
ECHO ON

date /t >> SendLogs.log

forfiles /p %DIR% /m access*.log /d -1 /c "pscp -C -q -2 -i %WORKDIR%\%HOST%.ppk @FILE %DEST%"

forfiles /p %DIR% /m access*.log /d -1 /c "cmd /c ren @FILE *.old"

forfiles /p %DIR% /m access*.old /d -14 /c "cmd /c DEL @FILE"{code}




Comments