Extrasection Regular expression substitution

Developers
Anonymous
2007-01-31
2012-10-11
  • Anonymous - 2007-01-31

    On the IIS log the server name in URL can be displayed with a capital letter or with a lower case letter in the beginning (for example "Demoserver" and "demoserver". How can I format these both to form a single result? With regular expression support this should be a cakewalk but I have yet to find the correct syntax to perform a substitution / replacement.

    I simplified this example a bit to avoid confusion. The following is bit silly but if it can be done, will solve my problem. So, if regex matches to either "demoserver" or "Demoserver" in the URL, it adds the matching value to the report.

    Currenly:

    ExtraSectionName1="Summary"
    ExtraSectionCodeFilter1="200 304"
    ExtraSectionCondition1="URL,Demoserver||URL,demoserver"
    ExtraSectionFirstColumnTitle1="Servers"
    ExtraSectionFirstColumnValues1="URL,(Demoserver)||URL,(demoserver)"
    ExtraSectionFirstColumnFormat1="%s"
    ExtraSectionStatTypes1=PBL
    ExtraSectionAddAverageRow1=0
    ExtraSectionAddSumRow1=0
    MaxNbOfExtra1=10
    MinHitExtra1=1

    The resulting custom report will look like this (as an example, IIS log contains four lines with "demoserver" and four with "Demoserver" server name in URL):

              Pages
    

    Demoserver 4
    demoserver 4

    What I want in my custom report is this:

              Pages
    

    Demoserver 8

    (or "demoserver 8", or even "DEMOSERVER 8", the format of the string does not matter, as long as it counts these values as ONE.. not listing two different servers in my report.

    I have tried the following, described in perl regex guide, but they wont work for me (im trying to do a substitution, replace "demoserver" with "Demoserver":

    ...
    ExtraSectionCondition1="URL,Demoserver||URL,demoserver"
    ExtraSectionFirstColumnTitle1="Servers"
    ExtraSectionFirstColumnValues1="URL,(s/demoserver/Demoserver/)"
    ExtraSectionFirstColumnFormat1="%s"
    ...

    and I also tried this (to process the lower case one, and leave the capital letter on intact)
    ...
    ExtraSectionCondition1="URL,Demoserver||URL,demoserver"
    ExtraSectionFirstColumnTitle1="Servers"
    ExtraSectionFirstColumnValues1="URL,(s/demoserver/Demoserver/)||URL,(Demoserver)"
    ExtraSectionFirstColumnFormat1="%s"
    ...

    also this (trying to substitute both, regardless of the first letter. Am I allowed to use '.' inside a group?):
    ...
    ExtraSectionCondition1="URL,Demoserver||URL,demoserver"
    ExtraSectionFirstColumnTitle1="Servers"
    ExtraSectionFirstColumnValues1="URL,(s/.emoserver/Demoserver/)"
    ExtraSectionFirstColumnFormat1="%s"
    ...

    ..and numerous other syntaxes.

    But.. none of these work. However, they don't generate errors when I build reports. Does awstats support the /s switch for substitution? If not, what is an alternative? Is my syntax way off? Am I trying the impossible? This is driving me insane.. please help.

     
    • Anonymous - 2007-02-01

      Changing the UrlNotCaseSensitive from 0 to 1 solved it. And there was much rejoicing.

       
    • Anonymous - 2007-02-01

      I guess I was looking at this from the wrong point of view, the following seemed to work:

      ExtraSectionName1="Summary"
      ExtraSectionCodeFilter1="200 304"
      ExtraSectionCondition1="URL,Demoserver||URL,demoserver"
      ExtraSectionFirstColumnTitle1="Servers"
      ExtraSectionFirstColumnValues1="URL,(emoserver)"
      ExtraSectionFirstColumnFormat1="D%s"
      ExtraSectionStatTypes1=PBL
      ExtraSectionAddAverageRow1=0
      ExtraSectionAddSumRow1=0
      MaxNbOfExtra1=10
      MinHitExtra1=1

      So, im actually trying to match "emoserver" and then just put a capital "D" in front of the first column format string. This solution seems somehow.. cheap :) But if it works.. hey.

       
    • Anonymous - 2007-02-01

      OK I'll take that back, although it only solved half of my problems. I can now do the server-specific reports using this solution but I also want to do a summary report of all servers.

      Example situation: I have in IIS log "Demoserver", "demoserver", "Secondserver", "secondserver"

      ExtraSectionName1="Summary"
      ExtraSectionCodeFilter1="200 304"
      ExtraSectionCondition1="URL,Demoserver||URL,demoserver||URL,Secondserver||URL,secondserver"
      ExtraSectionFirstColumnTitle1="Servers"
      ExtraSectionFirstColumnValues1="URL,(Demoserver)||URL,(demoserver)||URL,(Secondserver)||URL,(secondserver)"
      ExtraSectionFirstColumnFormat1="%s"
      ExtraSectionStatTypes1=PBL
      ExtraSectionAddAverageRow1=0
      ExtraSectionAddSumRow1=0
      MaxNbOfExtra1=10
      MinHitExtra1=1

      This report would give bad output (example):
      Pages
      Demoserver 4
      demoserver 4
      Secondserver 6
      secondserver 6

      I still want:
      Pages
      Demoserver 8
      Secondserver 12

      Now.. of course I cant do the thing I mentioned earlier as theres also "Secondserver" and that would result in "Decondserver" on the report. Oh the frustration.. any ideas? Im getting desperate.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks