[Y2K] inn-2.2.2/samples/innreport.in is old version ??

Fabien Tassin fta at oleane.net
Sun Jan 2 21:58:46 UTC 2000


According to Katsuhiro Kondou:
> 
> In article <20000101051126Q.kondou at inn.do.mms.mt.nec.co.jp>,
> 	Katsuhiro Kondou <kondou at nec.co.jp> wrote;
> 
> } Yes, I know this and saw the problem last year.
> } As for CURRENT, it's already fixed, but for STABLE
> } it's not.  When I committed this, I had wholly
> } forgotten Fabien's above comment.  I'll fix it
> 
> I've just upgaded 3.0.2 to see if this was
> fixed already.

I don't think it is.

>  But I don't see the problem
> is gone away.  Still the graphs and the order
> of stats seem to be broken :<

Unfortunatly, this problem can't be corrected by innreport once it appeared.
To correct it, you need to rename all broken filenames (1 html page and its
graphs [gif or png]) and update the content of 3 files accordingly
(innreport.db, index.html and the broken html report). The next run
will correct the index page and its graph.

Where does this problem came/come from ? 

syslog never logs the year but innreport has to decide what the
year of the *first* date read in the log was (to create a unique filename).. 
To do so, 3 dates are used :

- local time (T)
- the first (F) and the last (L) date read in the log (without the year)

Follow the code (from 3.0.2 as found in 2.3-CURRENT):

471  # The filename will contain the first date of the log or the current time.
472  my ($ts, $tm, $th, $dd, $dm, $dy) = localtime;
473  my ($m, $d, $h, $mn, $s) =
474    $first_date =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+)$/;
475  if ($m) {
476    my $ddm = (index "JanFebMarAprMayJunJulAugSepOctNovDec", $m) / 3;
477    # Adjust the year because syslog doesn't record it. We assume that
478    # it's the current year unless the last date is in the future.
479    $dy-- if (&ConvDate ("$last_date") > $ts + 60 * ($tm + 60 * ($th + 24 *
480       ($dd + substr("000031059090120151181212243273304334", $dm * 3, 3)))));
481    ($dm, $dd, $th, $tm, $ts) = ($ddm, $d, $h, $mn, $s);
482  }
483  $dm++; # because January = 0 and we prefer 1
484  $dy += 100 if $dy < 90; # Try to pacify the year 2000 !
485  $dy += 1900;
486  $suffix = sprintf ".%02d.%02d.%02d-%02d$SEPARATOR%02d$SEPARATOR%02d",
487                     $dy, $dm, $dd, $th, $tm, $ts;

A bug *could* occur Jan 1st depending upon both when innreport was invoked 
and what the last date found in the log was compared to the new year.

I propose this completly untested change :

Change line 479 by :

  my $ld = &ConvDate($last_date);
  $dy-- if $ld > $ts + 60 * ($tm + 60 * ($th + 24 * ($dd - 1 +
    substr("000031059090120151181212243273304334", $dm * 3, 3)))) ||
    $ld < &ConvDate($first_date);

Can someone check this, please ?

Note : It seams like there will be another problem March 1st because of
the leap year. The two instances of "000031059090120151181212243273304334"
should be substituted by "000031060091121152182213244274305335".
(it's not an exact value but as it is only used for comparisions, it
doesn't matter).

-- 
Fabien Tassin -+- fta at oleane.net



More information about the inn-workers mailing list