From: eldy <> Date: Tue, 3 Jul 2001 01:22:51 +0000 (+0000) Subject: Add number of new lines processed and corrupted during last update X-Git-Tag: AWSTATS_1_0~242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=996a099d6da12a3ac363c0263adc0ec14afa07fe;p=thirdparty%2FAWStats.git Add number of new lines processed and corrupted during last update --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 361c626b..b2a9f02c 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -49,7 +49,7 @@ $SiteToAnalyzeIsInHostAliases, $SiteToAnalyzeWithoutwww, $LogFile, $LogFormat, $LogFormatString, $Logo, $MaxNbOfDays, $MaxNbOfHostsShown, $MaxNbOfKeywordsShown, $MaxNbOfPageShown, $MaxNbOfRefererShown, $MaxNbOfRobotShown, $MinHitFile, $MinHitHost, $MinHitKeyword, $MinHitRefer, $MinHitRobot, $MonthRequired, -$NewDNSLookup, $NowNewLinePhase, $OpenFileError, $PROG, $PageBool, $PageCode, +$OpenFileError, $PROG, $PageBool, $PageCode, $PurgeLogFile, $QueryString, $RatioBytes, $RatioHits, $RatioHosts, $RatioPages, $ShowFlagLinks, $ShowLinksOnURL, $ShowLinksOnUrl, $TotalBytes, $TotalDifferentKeywords, $TotalDifferentPages, $TotalErrors, $TotalHits, @@ -1100,7 +1100,16 @@ sub Read_History_File { if ($field[0] eq "FirstTime") { $FirstTime{$_[0].$_[1]}=$field[1]; next; } if ($field[0] eq "LastTime") { if ($LastTime{$_[0].$_[1]} < $field[1]) { $LastTime{$_[0].$_[1]}=$field[1]; }; next; } if ($field[0] eq "TotalVisits") { $MonthVisits{$_[0].$_[1]}=$field[1]; next; } - if ($field[0] eq "LastUpdate") { if ($LastUpdate{$_[0].$_[1]} < $field[1]) { $LastUpdate{$_[0].$_[1]}=$field[1]; }; next; } + if ($field[0] eq "LastUpdate") { + if ($LastUpdate{$_[0].$_[1]} < $field[1]) { + $LastUpdate{$_[0].$_[1]}=$field[1]; + $LastUpdateLinesRead{$_[0].$_[1]}=$field[2]; + $LastUpdateNewLinesRead{$_[0].$_[1]}=$field[3]; + $LastUpdateLinesCorrupted{$_[0].$_[1]}=$field[4]; + $LastUpdateNewLinesCorrupted{$_[0].$_[1]}=$field[5]; + }; + next; + } if ($field[0] eq "BEGIN_VISITOR") { $readvisitor=1; next; } if ($field[0] eq "END_VISITOR") { $readvisitor=0; next; } if ($field[0] eq "BEGIN_UNKNOWNIP") { $readunknownip=1; next; } @@ -1224,7 +1233,7 @@ sub Save_History_File { print HISTORYTMP "FirstTime $FirstTime{$_[0].$_[1]}\n"; print HISTORYTMP "LastTime $LastTime{$_[0].$_[1]}\n"; if ($LastUpdate{$_[0].$_[1]} lt "$nowyear$nowmonth$nowday$nowhour$nowmin$nowsec") { $LastUpdate{$_[0].$_[1]}="$nowyear$nowmonth$nowday$nowhour$nowmin$nowsec"; } - print HISTORYTMP "LastUpdate $LastUpdate{$_[0].$_[1]}\n"; + print HISTORYTMP "LastUpdate $LastUpdate{$_[0].$_[1]} $NbOfLinesProcessed $NbOfNewLinesProcessed $NbOfLinesCorrupted $NbOfNewLinesCorrupted\n"; print HISTORYTMP "TotalVisits $MonthVisits{$_[0].$_[1]}\n"; print HISTORYTMP "BEGIN_DOMAIN\n"; @@ -1683,7 +1692,9 @@ if ($UpdateStats) { &debug("Start of processing log file $LogFile (monthtoprocess=$monthtoprocess, yeartoprocess=$yeartoprocess)"); $OpenFileError=1; if (open(LOG,"$LogFile")) { $OpenFileError=0; } if ($OpenFileError) { error("Error: Couldn't open server log file \"$LogFile\" : $!"); } - $NbOfLinesProcessed=0; $NowNewLinePhase=0; + $NbOfLinesProcessed=0; $NbOfLinesCorrupted=0; + $NbOfNewLinesProcessed=0; $NbOfNewLinesCorrupted=0; + $NowNewLinePhase=0; while () { $savedline=$_; @@ -1701,8 +1712,8 @@ if ($UpdateStats) { # Check parsed parameters #---------------------------------------------------------------------- if ($field[$pos_code] eq "") { - $corrupted++; - if ($NbOfLinesProcessed >= 10 && $corrupted == $NbOfLinesProcessed) { + $NbOfLinesCorrupted++; + if ($NbOfLinesProcessed >= 10 && $NbOfLinesCorrupted == $NbOfLinesProcessed) { # Files seems to have bad format print "AWStats did not found any valid log lines that match your LogFormat parameter, in the 10th first non commented lines of your log.
\n"; print "Your log file $LogFile must have a bad format or LogFormat parameter setup is wrong.

\n"; @@ -1720,17 +1731,18 @@ if ($UpdateStats) { print "$LogFormat
\n"; } print "
"; - print "This is a sample of what AWStats found (10th non commented line):
\n"; + print "And this is a sample of what AWStats found (the 10th non commented line):
\n"; print "$_
\n"; error(""); # Exit with format error } + next; } # Check filters #---------------------------------------------------------------------- if ($field[$pos_method] ne 'GET' && $field[$pos_method] ne 'POST' && $field[$pos_method] !~ /OK/) { next; } # Keep only GET, POST but not HEAD, OPTIONS - if ($field[$pos_url] =~ /^RC=/) { $corrupted++; next; } # A strange log record with IIS we need to forget + if ($field[$pos_url] =~ /^RC=/) { $NbOfLinesCorrupted++; next; } # A strange log record with IIS we need to forget # Split DD/Month/YYYY:HH:MM:SS or YYYY-MM-DD HH:MM:SS or MM/DD/YY\tHH:MM:SS $field[$pos_date] =~ tr/-\/ \t/::::/; @dateparts=split(/:/,$field[$pos_date]); @@ -1740,8 +1752,8 @@ if ($UpdateStats) { # Create $timeconnexion like YYYYMMDDHHMMSS my $timeconnexion=$dateparts[2].$dateparts[1].$dateparts[0].$dateparts[3].$dateparts[4].$dateparts[5]; my $dayconnexion=$dateparts[2].$dateparts[1].$dateparts[0]; - if ($timeconnexion < 10000000000000) { $corrupted++; next; } # Should not happen, kept in case of parasite/corrupted line - if ($timeconnexion > $timetomorrow) { $corrupted++; next; } # Should not happen, kept in case of parasite/corrupted line + if ($timeconnexion < 10000000000000) { $NbOfLinesCorrupted++; next; } # Should not happen, kept in case of parasite/corrupted line + if ($timeconnexion > $timetomorrow) { $NbOfLinesCorrupted++; next; } # Should not happen, kept in case of parasite/corrupted line # Skip if not a new line #----------------------- @@ -1753,12 +1765,16 @@ if ($UpdateStats) { $NowNewLinePhase=1; # This will stop comparison "<=" between timeconnexion and LastTime (we should have only new lines now) } + # Record is approved. We found a new line + #---------------------------------------- + $NbOfNewLinesProcessed++; + if (&SkipHost($field[$pos_rc])) { next; } # Skip with some client host IP addresses if (&SkipFile($field[$pos_url])) { next; } # Skip with some URLs if (! &OnlyFile($field[$pos_url])) { next; } # Skip with other URLs - # Record is approved. We found a new line. Is it in a new month section ? - #------------------------------------------------------------------------ + # Is it in a new month section ? + #------------------------------- if ((($dateparts[1] > $monthtoprocess) && ($dateparts[2] >= $yeartoprocess)) || ($dateparts[2] > $yeartoprocess)) { # Yes, a new month to process if ($monthtoprocess > 0) { @@ -1778,7 +1794,7 @@ if ($UpdateStats) { next; } else { # Bad format record (should not happen but when using MSIndex server), next - $corrupted++; next; + $NbOfNewLinesCorrupted++; next; } } @@ -2336,12 +2352,21 @@ print "$CENTER
"; print ""; print ""; print "\n"; print "\n"; print "";
$message[7]: $SiteToAnalyze
$message[75]: "; -foreach $key (keys %LastUpdate) { if ($LastUpdate < $LastUpdate{$key}) { $LastUpdate = $LastUpdate{$key}; } } +foreach $key (keys %LastUpdate) { if ($LastUpdate < $LastUpdate{$key}) { $choosedkey=$key; $LastUpdate = $LastUpdate{$key}; } } $yearcon=substr($LastUpdate,0,4);$monthcon=substr($LastUpdate,4,2);$daycon=substr($LastUpdate,6,2);$hourcon=substr($LastUpdate,8,2);$mincon=substr($LastUpdate,10,2); -if ($LastUpdate != 0) { print "$daycon $monthlib{$monthcon} $yearcon - $hourcon:$mincon"; } +if ($LastUpdate != 0) { print "$daycon $monthlib{$monthcon} $yearcon - $hourcon:$mincon  "; } else { print "Never updated"; } print "       "; -if ($AllowToUpdateStatsFromBrowser) { print "$message[74]"; } +if ($UpdateStats) { + print " (New lines processed: $NbOfNewLinesProcessed, New lines corrupted: $NbOfNewLinesCorrupted)"; +} +else { + print " (New lines processed: $LastUpdateNewLinesRead{$choosedkey}, New lines corrupted: $LastUpdateNewLinesCorrupted{$choosedkey})"; +} +if ($AllowToUpdateStatsFromBrowser) { + print "
 "; + print "$message[74]"; +} print "
 
$message[16]: