Your message dated Fri, 18 Oct 2013 03:20:52 +0400
with message-id <[email protected]>
and subject line Re: Bug#706491: awstats: update.sh is not logrotate compatible
has caused the Debian Bug report #706491,
regarding awstats: update.sh is not logrotate compatible
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
706491: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=706491
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: awstats
Version: 6.9.5~dfsg-5
Severity: normal

/usr/share/awstats/tools/update.sh is automatically executed by cron, but
when the logfiles are rotated the timespan between the last execution time
and the current time is missing in the statistics.

This becomes a major issue if people increase the cron interval.

A possible solution is to use a wrapper script for the logfiles (see
attached getlogs.pl). This script can be used by prepending it to Logfile in
/etc/awstats/awstats.conf (e.g. LogFile="getlogs.pl 
/var/log/apache2/access.log")
and getlogs.pl will use access.log.1 and access.log by default.

The very same script can also be used in order to create stats for all
existing rotated log files by using "all" as a second cli parameter or
setting USELOGFILES='all'. The current behavior can be emulated by using
'current' as the second cli parameter.

-- System Information:
Debian Release: 6.0.7
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages awstats depends on:
ii  perl                   5.10.1-17squeeze6 Larry Wall's Practical Extraction 

Versions of packages awstats recommends:
ii  coreutils                     8.5-1      GNU core utilities
ii  libnet-xwhois-perl            0.90-3     Whois Client Interface for Perl5

Versions of packages awstats suggests:
ii  apache2               2.2.16-6+squeeze11 Apache HTTP Server metapackage
ii  apache2-mpm-worker [h 2.2.16-6+squeeze11 Apache HTTP Server - high speed th
pn  libgeo-ipfree-perl    <none>             (no description available)
pn  libnet-dns-perl       <none>             (no description available)
pn  libnet-ip-perl        <none>             (no description available)
pn  liburi-perl           <none>             (no description available)

-- no debconf information
#!/usr/bin/perl
##
## getlogs.pl, written by Sven Strickroth <[email protected]> (2013)
##
## Provides (possible rotated) logfiles to awstats
##

use strict;
use File::Basename;

if ($#ARGV + 1 < 1 || $#ARGV > 1 || !$ARGV[0]) {
  print "Call this with ".$0." logfilename [CURRENTLAST|CURRENT|ALL|LAST]\n";
  print "\n";
  print "If the second parameter is omitted CURRENTLAST (or the content of the environment\n";
  print "variable USELOGFILES will be used) will be used by default (i.e. logfilename.1 and\n";
  print "logfilename will be printed).\n";
  exit 1;
}

my $path = dirname($ARGV[0]);
my $baselogfilename = basename($ARGV[0]);

die('Logfile path does not exist: ' . $path . "\n") unless (-d $path);

$ARGV[1] = $ENV{'USELOGFILES'} if ($ARGV[1] eq '');

if (lc($ARGV[1]) eq 'last') {
 if (-f $ARGV[0] . '.1') {
   &catFile($ARGV[0] . '.1');
 } elsif (-f $ARGV[0] . '.1.gz') {
   &catFile($ARGV[0] . '.1.gz');
 }
} elsif (lc($ARGV[1]) eq 'all') {
  opendir(my $dirh, $path) or die ("could not list $path\n");
  my @dir = readdir($dirh);
  closedir($dirh);
  @dir = grep {$_ =~ /^$baselogfilename/} @dir;
  my $filenamelen = length($baselogfilename) + 1;
  # order by number reversed
  @dir = reverse sort {substr($a, $filenamelen) <=> substr($b, $filenamelen)} @dir;
  foreach my $entry (@dir) {
    &catFile($path . '/' . $entry);
  }
} elsif (lc($ARGV[1]) eq 'current') {
  &catFile($ARGV[0]);
} else {
 if (-f $ARGV[0] . '.1') {
   &catFile($ARGV[0] . '.1');
 }
 elsif (-f $ARGV[0] . '.1.gz') {
   &catFile($ARGV[0] . '.1.gz');
 }
 if (-f $ARGV[0]) {
  &catFile($ARGV[0]);
 }
}
exit 0;

sub catFile() {
  my ($file) = @_;
  if ($file =~ /\.gz$/) {
   open(my $fh, "gunzip < $file |") or die("could not open $file\n");
   while (<$fh>) {
     print $_;
   }
   close($fh);
  } else {
   open(my $fh, "<", $file) or die("could not open $file\n");
   while (<$fh>) {
     print $_;
   }
   close($fh);
  }
}

--- End Message ---
--- Begin Message ---
Hello,

I don't see why exactly update.sh is not logrotate compatible.
Please, take look on the section "A few minutes is lost each
day/week/month" in the README.Debian.

On Wed, May 1, 2013 at 12:24 AM, Sven Strickroth <[email protected]> wrote:
> /usr/share/awstats/tools/update.sh is automatically executed by cron, but
> when the logfiles are rotated the timespan between the last execution time
> and the current time is missing in the statistics.
>
> This becomes a major issue if people increase the cron interval.
>
> A possible solution is to use a wrapper script for the logfiles (see
> attached getlogs.pl). This script can be used by prepending it to Logfile 
> in
> /etc/awstats/awstats.conf (e.g. 
> LogFile="getlogs.pl/var/log/apache2/access.log")
> and getlogs.pl will use access.log.1 and access.log by default.
>
> The very same script can also be used in order to create stats for all
> existing rotated log files by using "all" as a second cli parameter or
> setting USELOGFILES='all'. The current behavior can be emulated by using
> 'current' as the second cli parameter.

--- End Message ---

Reply via email to