From: Pete Beardmore Date: Sat, 11 Jan 2014 14:16:49 +0000 (+0000) Subject: optionally add host column in error code reports X-Git-Tag: AWSTATS_7_4~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95c15e5ff7a636d1852ce406d552e4edf825d2b3;p=thirdparty%2FAWStats.git optionally add host column in error code reports --- diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 2d75829c..36948728 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -1081,6 +1081,11 @@ ShowMiscStats=a # Default: 1, Possible column codes: None ShowHTTPErrorsStats=1 +# Show http error page details +# Context: Web, Streaming +# Default: R, Possible column codes: RH +ShowHTTPErrorsPageDetail=R + # Show smtp errors chart (For use when analyzing mail log files) # Context: Mail # Default: 0, Possible column codes: None diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl old mode 100755 new mode 100644 index 58ef34f2..145a4241 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -254,7 +254,7 @@ use vars qw/ $ShowHoursStats $ShowDomainsStats $ShowHostsStats $ShowRobotsStats $ShowSessionsStats $ShowPagesStats $ShowFileTypesStats $ShowDownloadsStats $ShowOSStats $ShowBrowsersStats $ShowOriginStats - $ShowKeyphrasesStats $ShowKeywordsStats $ShowMiscStats $ShowHTTPErrorsStats + $ShowKeyphrasesStats $ShowKeywordsStats $ShowMiscStats $ShowHTTPErrorsStats $ShowHTTPErrorsPageDetail $AddDataArrayMonthStats $AddDataArrayShowDaysOfMonthStats $AddDataArrayShowDaysOfWeekStats $AddDataArrayShowHoursStats /; ( @@ -285,6 +285,7 @@ use vars qw/ $ShowKeywordsStats, $ShowMiscStats, $ShowHTTPErrorsStats, + $ShowHTTPErrorsPageDetail, $AddDataArrayMonthStats, $AddDataArrayShowDaysOfMonthStats, $AddDataArrayShowDaysOfWeekStats, @@ -534,7 +535,7 @@ use vars qw/ %_worm_h %_worm_k %_worm_l %_login_h %_login_p %_login_k %_login_l %_screensize_h %_misc_p %_misc_h %_misc_k %_cluster_p %_cluster_h %_cluster_k - %_se_referrals_p %_se_referrals_h %_sider_h %_referer_h %_url_p %_url_k %_url_e %_url_x + %_se_referrals_p %_se_referrals_h %_sider_h %_referer_h %_err_host_h %_url_p %_url_k %_url_e %_url_x %_downloads %_unknownreferer_l %_unknownrefererbrowser_l %_emails_h %_emails_k %_emails_l %_emailr_h %_emailr_k %_emailr_l @@ -2756,6 +2757,7 @@ sub Check_Config { if ( $ShowClusterStats !~ /[01PHB]/ ) { $ShowClusterStats = 0; } if ( $ShowMiscStats !~ /[01anjdfrqwp]/ ) { $ShowMiscStats = 'a'; } if ( $ShowHTTPErrorsStats !~ /[01]/ ) { $ShowHTTPErrorsStats = 1; } + if ( $ShowHTTPErrorsPageDetail !~ /[RH]/ ) { $ShowHTTPErrorsPageDetail = 'R'; } if ( $ShowSMTPErrorsStats !~ /[01]/ ) { $ShowSMTPErrorsStats = 0; } if ( $AddDataArrayMonthStats !~ /[01]/ ) { $AddDataArrayMonthStats = 1; } @@ -5835,8 +5837,15 @@ sub Read_History_With_TmpUpdate { } if ( $withupdate || $HTMLOutput{"errors$code"} ) { - if ( $field[2] ) { - $_referer_h{$code}{$field[0]} = $field[2]; + my $fieldidx = 2; + foreach (split(//, $ShowHTTPErrorsPageDetail)) { + last if (! $field[$fieldidx] ); + if ( $_ =~ /R/i ) { + $_referer_h{$code}{$field[0]} = $field[2]; + } elsif ( $_ =~ /H/i ) { + $_err_host_h{$code}{$field[0]} = $field[$fieldidx]; + } + $fieldidx++; } } } @@ -5876,6 +5885,7 @@ sub Read_History_With_TmpUpdate { if ($withpurge) { %_sider_h = (); %_referer_h = (); + %_err_host_h = (); } } if ( !scalar %SectionsToLoad ) { @@ -7283,7 +7293,11 @@ sub Save_History { print HISTORYTMP "
\n"; } print HISTORYTMP - "# URL with $code errors - Hits - Last URL referer\n"; + "# URL with $code errors - Hits" + . ($ShowHTTPErrorsPageDetail =~ /R/i ? " - Last URL referrer" : '') + . ($ShowHTTPErrorsPageDetail =~ /H/i ? " - Host" : '') + . "\n"; + $ValueInFile{$sectiontosave} = tell HISTORYTMP; print HISTORYTMP "${xmlbb}BEGIN_SIDER_$code${xmlbs}" . ( scalar keys %{$_sider_h{$code}} ) @@ -7291,10 +7305,12 @@ sub Save_History { foreach ( keys %{$_sider_h{$code}} ) { my $newkey = $_; my $newreferer = $_referer_h{$code}{$_} || ''; + my $newhost = $_err_host_h{$code}{$_} || ''; print HISTORYTMP "${xmlrb}" . XMLEncodeForHisto($newkey) - . "${xmlrs}$_sider_h{ $code }{$_}${xmlrs}" - . XMLEncodeForHisto($newreferer) + . "${xmlrs}$_sider_h{ $code }{$_}" + . ($ShowHTTPErrorsPageDetail =~ /R/i ? "${xmlrs}" . XMLEncodeForHisto($newreferer) : '') + . ($ShowHTTPErrorsPageDetail =~ /H/i ? "${xmlrs}" . XMLEncodeForHisto($newhost) : '') . "${xmlre}\n"; } print HISTORYTMP "${xmleb}END_SIDER_$code${xmlee}\n"; @@ -7718,7 +7734,7 @@ sub Init_HashArray { %_login_l = %_screensize_h = (); %_misc_p = %_misc_h = %_misc_k = (); %_cluster_p = %_cluster_h = %_cluster_k = (); - %_se_referrals_p = %_se_referrals_h = %_sider_h = %_referer_h = + %_se_referrals_p = %_se_referrals_h = %_sider_h = %_referer_h = %_err_host_h = %_url_p = %_url_k = %_url_e = %_url_x = (); %_downloads = (); %_unknownreferer_l = %_unknownrefererbrowser_l = (); @@ -11618,7 +11634,15 @@ sub HTMLShowErrorCodes{ &tab_head( $title, 19, 0, "errors$code" ); print "URL (" . Format_Number(( scalar keys %{$_sider_h{$code}} )) - . ")$Message[49]$Message[23]\n"; + . ")$Message[49]"; + foreach (split(//, $ShowHTTPErrorsPageDetail)) { + if ( $_ =~ /R/i ) { + print "$Message[23]"; + } elsif ( $_ =~ /H/i ) { + print "$Message[81]"; + } + } + print "\n"; my $total_h = 0; my $count = 0; &BuildKeyList( $MaxRowsInHTMLOutput, 1, \%{$_sider_h{$code}}, @@ -11628,10 +11652,16 @@ sub HTMLShowErrorCodes{ #if (length($nompage)>$MaxLengthOfShownURL) { $nompage=substr($nompage,0,$MaxLengthOfShownURL)."..."; } my $referer = XMLEncode( CleanXSS( $_referer_h{$code}{$key} ) ); + my $host = XMLEncode( CleanXSS( $_err_host_h{$code}{$key} ) ); print "$nompage"; print "".Format_Number($_sider_h{$code}{$key}).""; - print "" - . ( $referer ? "$referer" : " " ) . ""; + foreach (split(//, $ShowHTTPErrorsPageDetail)) { + if ( $_ =~ /R/i ) { + print "" . ( $referer ? "$referer" : " " ) . ""; + } elsif ( $_ =~ /H/i ) { + print "" . ( $host ? "$host" : " " ) . ""; + } + } print "\n"; my $total_s += $_sider_h{$code}{$key}; $count++; @@ -18797,18 +18827,25 @@ if ( $UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft' ) foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) { if ( $field[$pos_code] == $code ) { - # This is an error code which referrer need to be tracked + # This is an error code which referrer need to be tracked my $newurl = substr( $field[$pos_url], 0, $MaxLengthOfStoredURL ); $newurl =~ s/[$URLQuerySeparators].*$//; $_sider_h{$code}{$newurl}++; - if ( $pos_referer >= 0 ) { + if ( $pos_referer >= 0 && $ShowHTTPErrorsPageDetail =~ /R/i ) { my $newreferer = $field[$pos_referer]; if ( !$URLReferrerWithQuery ) { $newreferer =~ s/[$URLQuerySeparators].*$//; } $_referer_h{$code}{$newurl} = $newreferer; + } + if ( $pos_host >= 0 && $ShowHTTPErrorsPageDetail =~ /H/i ) { + my $newhost = $field[$pos_host]; + if ( !$URLReferrerWithQuery ) { + $newhost =~ s/[$URLQuerySeparators].*$//; + } + $_err_host_h{$code}{$newurl} = $newhost; last; } }