« Previous Next »

Answered Thread: Simple Query Help

Last post 12-22-2008 9:50 PM by Hitchheik. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 12-17-2008, 6:00 PM

    • blmorris
    • Not Ranked
    • Joined on 12-17-2008, 10:56 PM
    • Posts 2

    Simple Query Help

     Hey all.  I am very new to Log Parser.  By 'very new', I mean 'I have never used it and don't have a clue'.

     I am looking to write a simple quesr that can tell me how many hits I get to my IIS website.  The site is the only one on the server, so I suppse that simplifies it a little bit.

     That's is really.  I am not a SQL guy either... the extent of my 'scripting' is .cmd files.

     Anyone know of a great starting resource for figuring out they syntax?

     

    Thanks!

  • 12-17-2008, 11:10 PM In reply to

    Answered Re: Simple Query Help

    See my advice here:

    http://forums.iis.net/t/1153607.aspx

  • 12-18-2008, 9:13 AM In reply to

    • blmorris
    • Not Ranked
    • Joined on 12-17-2008, 10:56 PM
    • Posts 2

    Re: Simple Query Help

     Thanks!

     

    I also downloaded Lizarl's GUI for LogParser... hopefully that will get me taken care of. :)

  • 12-22-2008, 9:50 PM In reply to

    Re: Simple Query Help

     This is a VBScript that will display an hourly count of your hits. Save top as Hourly.vbs, Save the  bottom file in the same directory as your output path as hour_3.xsl.  This will open in Explorer when completed'

    '===================================================================================
    '************************** Set Input and Output formats  ******************************
    Set objLogParser = CreateObject("MSUtil.LogQuery")
    Set objInputFormat = CreateObject("MSUtil.LogQuery.IISW3CInputFormat")
    Set objOutputFormat = CreateObject("MSUtil.LogQuery.XMLOutputFormat")
    '===================================================================================
    '********************************* Set String inputs  **********************************
    strPath = inputbox ("Where do you want to store output?","Directory Location","c:\scripts\LogParser\")
    strComputer = inputbox ("Which Server log to Review","Server Log","ServerName")
    strSite = inputbox ("Which Site log to Review","Site Log","1")
    strWhen = inputbox("Which Date to look at? YYMMDD format","Date Entry","081217")

    objOutputFormat.xslLink = strPath & "Hour_3.xsl"
    outputfile = strPath  & strComputer & "_WebHitPerHour.xml"
    '===================================================================================
    '******************************** Insert Query here  **********************************
    strQuery = "SELECT TO_STRING(time, 'HH') AS HOUR, TO_STRING(TO_LOCALTIME(time), 'HH') AS LOCAL, COUNT(*) AS Hits INTO " & outputfile & " FROM \\" & strComputer & "\c$\Logfiles\W3SVC" & strSite & "\ex" & strWhen & ".log GROUP BY Hour, LOCAL ORDER BY Hour ASC"
    '===================================================================================
    '******************************** This calls the job   **********************************
    objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat
    '===================================================================================
    'Z1 ************************ Open file to read *****************************************
    Set objShell = Wscript.CreateObject("Wscript.Shell")
    objShell.Run outputfile

    '********************************************************************************************

    'Next file

    '*****************************************************************************************

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

     <xsl:template match="/">
      <xsl:for-each select="ROOT">
       <HTML>
        <HEAD><TITLE><xsl:value-of select="@CREATED_BY"/> Generated Log</TITLE></HEAD>
        <BODY>

         <CENTER><H1><xsl:value-of select="@CREATED_BY"/> Generated Log</H1></CENTER>
         <CENTER><H2>Generated on <xsl:value-of select="@DATE_CREATED"/></H2></CENTER>
         <CENTER><H2><FONT color="Blue">Hourly Hits</FONT></H2></CENTER>

         
         <CENTER>
          <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5">
        <TR bgcolor="#9acd32">
         <TH>GMT</TH>
        <TH>Local</TH>
        <TH>Count</TH>
        </TR>
           <xsl:apply-templates select="ROW"/>
          </TABLE>
         </CENTER>

        </BODY>
       </HTML>
      </xsl:for-each>
     </xsl:template>
     <xsl:template match="ROW">
          <TR BGCOLOR="#F0F0F0">
        <xsl:for-each select="*">
         <TD>
          <xsl:value-of select="."/>
         </TD>
        </xsl:for-each>
          </TR>
     </xsl:template>

    </xsl:stylesheet>

     '*****************************************************************

    Jerome

Page 1 of 1 (4 items)
Microsoft Communities