SourceForge has been redesigned. Learn more.
Close

Extra Section Regex

Demnogonis
2012-02-27
2012-10-11
  • Demnogonis

    Demnogonis - 2012-02-27

    Hi,

    I want to create an extra section, which shows the executed perl scripts and
    their action parameter like this:

    Action                            Pages  Hits
    foo.pl?action=foo       1234     1234
    foo.pl?action=bar       1234     1234
    bar.pl?action=foo       5678     5678
    ...
    

    My actual config looks like this:

    ExtraSectionName1="Actions"
    ExtraSectionCodeFilter1="200 304"
    ExtraSectionCondition1="URL,\/cgi\-bin\/.+\.pl"
    ExtraSectionFirstColumnTitle1="Action"
    ExtraSectionFirstColumnValues1="URLWITHQUERY,([a-zA-Z0-9]+\.pl.*action=[a-zA-Z0-9]+)"
    ExtraSectionFirstColumnFormat1="%s"
    ExtraSectionStatTypes1=HPB
    ExtraSectionAddAverageRow1=0
    ExtraSectionAddSumRow1=1
    MaxNbOfExtra1=20
    MinHitExtra1=1
    

    It works so far, but there are many other parameters, which mess up the
    result. So I tried this:

    ExtraSectionFirstColumnValues1="URLWITHQUERY,([a-zA-Z0-9]+\.pl\?).*(action=[a-zA-Z0-9]+)"
    

    The problem is that AWStats only gets the data from the first pair of
    brackets.

    Is there any way to make it read the whole regex? Any code snippets?

    Regards,

    Demno

     
  • Demnogonis

    Demnogonis - 2012-02-28

    I solved it by myself.

    # The section to extract the values from the logfile. Line 19693 - 19701 in awstats.pl
    elsif ( $rowkeytype eq 'URLWITHQUERY' ) {
        if ( "$urlwithnoquery$tokenquery$standalonequery" =~
            /$rowkeytypeval/ )
        {
            $rowkeyval = "$1$2";  # Just added a $2 to the string to get the second capture group.
            $rowkeyok  = 1;
            last;
        }
    }
    

    Wouldn't the extra section become much more powerful when every rowkeytype had
    three or more possible capture groups?

    Regards,
    Demno

    PS:

    Forgive me that I am posting development stuff in the General Discussion
    forum.

     

Log in to post a comment.