From: eldy <> Date: Sat, 7 Jun 2003 18:49:02 +0000 (+0000) Subject: Cut URL found with 404 errors to a length of 256 (To avoid memory problems with very... X-Git-Tag: AWSTATS_5_6_BETA~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82f885ac19bd0c852b69db54eee9a3a173b25b32;p=thirdparty%2FAWStats.git Cut URL found with 404 errors to a length of 256 (To avoid memory problems with very large worms URL reported in log files). --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 6e09c6ee..49099f41 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -78,6 +78,9 @@ $DNSLastUpdateCacheFile $LogScreenSizeUrl $Lang $MaxRowsInHTMLOutput +$MaxLengthOfURL +$MaxLengthOfStoredURL +$MaxLengthOfStoredUA $BarImageVertical_v $BarImageVertical_u $BarImageVertical_p @@ -95,6 +98,8 @@ $DNSLastUpdateCacheFile='dnscachelastupdate.txt'; $LogScreenSizeUrl='logscreensizeurl'; $Lang='auto'; $MaxRowsInHTMLOutput = 1000; +$MaxLengthOfStoredURL=256; # Note: Apache LimitRequestLine is default to 8190 +$MaxLengthOfStoredUA=256; $BarImageVertical_v = 'vv.png'; #$BarImageHorizontal_v = 'hv.png'; $BarImageVertical_u = 'vu.png'; @@ -110,7 +115,7 @@ $BarImageVertical_k = 'vk.png'; $BarImageHorizontal_k = 'hk.png'; use vars qw/ $EnableLockForUpdate $DNSLookup $AllowAccessFromWebToAuthenticatedUsersOnly -$BarHeight $BarWidth $CreateDirDataIfNotExists $KeepBackupOfHistoricFiles $MaxLengthOfURL +$BarHeight $BarWidth $CreateDirDataIfNotExists $KeepBackupOfHistoricFiles $NbOfLinesParsed $NbOfLinesDropped $NbOfLinesCorrupted $NbOfOldLines $NbOfNewLines $NbOfLinesShowsteps $NewLinePhase $NbOfLinesForCorruptedLog $PurgeLogFile $ShowAuthenticatedUsers $ShowFileSizesStats $ShowScreenSizeStats @@ -130,7 +135,7 @@ $ShowEMailSenders, $ShowEMailReceivers, $AuthenticatedUsersNotCaseSensitive, $Expires, $UpdateStats, $MigrateStats, $URLNotCaseSensitive, $URLWithQuery, $URLReferrerWithQuery, $UseFramesWhenCGI, $DecodeUA)= -(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); +(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); use vars qw/ $AllowToUpdateStatsFromBrowser $ArchiveLogRecords $DetailedReportsOnNewWindows $FirstDayOfWeek $KeyWordsNotSensitive $SaveDatabaseFilesWithPermissionsForEveryone @@ -4336,7 +4341,7 @@ sub DefinePerlParsingFormat { $LogFormatString =~ s/%{mod_gzip_input_size}n/%gzipin/g; $LogFormatString =~ s/%{mod_gzip_output_size}n/%gzipout/g; $LogFormatString =~ s/%{mod_gzip_compression_ratio}n/%gzipratio/g; - $LogFormatString =~ s/\(%{ratio}n\)/%gzipratio/g; + $LogFormatString =~ s/\(%{ratio}n\)/%deflateratio/g; # Replacement for a IIS and ISA format string $LogFormatString =~ s/cs-uri-query/%query/g; # Must be before cs-uri $LogFormatString =~ s/date\stime/%time2/g; @@ -5184,9 +5189,9 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat next; } # We found a new line. This will replace comparison "<=" with "<" between timerecord and LastLine (we should have only new lines now) - $NewLinePhase=1; + $NewLinePhase=1; # We will never enter here again if ($ShowSteps) { - if ($NbOfLinesShowsteps > 1 && (($NbOfLinesShowsteps & $NBOFLINESFORBENCHMARK) != 0)) { + if ($NbOfLinesShowsteps > 1 && ($NbOfLinesShowsteps & $NBOFLINESFORBENCHMARK)) { my $delay=&GetDelaySinceStart(0); print "".($NbOfLinesParsed-1)." lines processed (".($delay>0?$delay:1000)." ms, ".int(1000*($NbOfLinesShowsteps-1)/($delay>0?$delay:1000))." lines/second)\n"; } @@ -5209,10 +5214,6 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat - - - - # Skip for some client host IP addresses, some URLs, other URLs if (@SkipHosts && (&SkipHost($field[$pos_host]) || ($pos_hostr && &SkipHost($field[$pos_host])))) { $qualifdrop="Dropped record (host $field[$pos_host] not qualified by SkipHosts)"; } elsif (@SkipFiles && &SkipFile($field[$pos_url])) { $qualifdrop="Dropped record (URL $field[$pos_url] not qualified by SkipFiles)"; } @@ -5268,7 +5269,7 @@ if ($UpdateStats && $FrameName ne 'index' && $FrameName ne 'mainleft') { # Updat $_errors_k{$field[$pos_code]}+=int($field[$pos_size]); foreach my $code (keys %TrapInfosForHTTPErrorCodes) { if ($field[$pos_code] == $code) { - my $newurl=$field[$pos_url]; + my $newurl=substr($field[$pos_url],0,$MaxLengthOfStoredURL); $newurl =~ s/[$URLQuerySeparators].*$//; $_sider404_h{$newurl}++; my $newreferer=$field[$pos_referer]; @@ -7472,15 +7473,31 @@ if (scalar keys %HTMLOutput) { print "$Center 
\n"; &tab_head($Message[47],19); print "URL (".(scalar keys %_sider404_h).")$Message[49]$Message[23]\n"; + $total_h=0; my $count=0; &BuildKeyList($MaxRowsInHTMLOutput,1,\%_sider404_h,\%_sider404_h); foreach my $key (@keylist) { my $nompage=CleanFromCSSA($key); #if (length($nompage)>$MaxLengthOfURL) { $nompage=substr($nompage,0,$MaxLengthOfURL)."..."; } my $referer=CleanFromCSSA($_referer404_h{$key}); - print "$nompage$_sider404_h{$key}".($referer?"$referer":" ")."\n"; + print "$nompage"; + print "$_sider404_h{$key}"; + print "".($referer?"$referer":" ").""; + print "\n"; + $total_s += $_sider404_h{$key}; $count++; } + # TODO Build TotalErrorHits +# if ($Debug) { debug("Total real / shown : $TotalErrorHits / $total_h",2); } +# $rest_h=$TotalErrorHits-$total_h; +# if ($rest_h > 0) { +# my $p; +# if ($TotalErrorHits) { $p=int($rest_h/$TotalErrorHits*1000)/10; } +# print "$Message[30]"; +# print "$rest_h"; +# print "..."; +# print "\n"; +# } &tab_end; &html_end; }