Hi, On Thu, 22 Jan 2004 15:12:06 -0600 Wagner One <[EMAIL PROTECTED]> wrote:
> On 1/22/2004 1:15 PM, Bob Apthorpe wrote: > > > Note: I think this my hacked-up version of sa-stats.pl at > > http://www.cynistar.net/~apthorpe/code/sa-contrib/sa-stats.pl > > > > I'm not sure where the canonical version of sa-stats.pl lives since the > > migration from Sourceforge/CVS to Apache/SVN. I worked from the source at > > http://cvs.sourceforge.net/viewcvs.py/spamassassin/spamassassin/tools/sa-stats > > .pl and I think Duncan fixed some date problems in my patch involving the new > > year before committing it. The current version is probably in Apache's SVN > > repository but I have no clue where that is, how to browse it, etc. :/ > > I've tried both of these, running as root on my mail box (installing > Parse::Syslog first for your version, Bob) and get all zeros in the report > too. > > I ran the same test you did, Bob, on the fragment in a previous message and > got expected results... the same output as you received. > > When I run Bob's on my /var/log/maillog, it spews: > > WARNING: ignoring future date in syslog line: Apr 6 04:00:10 > > For around 1600 seconds and the report has all zeros in it for all fields > (hey, it's a slow box :) Okay, that question I can answer (see previous post to Matthias). My code uses a naive (simple, stupid) way of deriving the year: 102 my $YEAR = (localtime(time))[5]; # this is years since 1900 103 104 my $parser = Parse::Syslog->new( $opt{'logfile'}, 105 year => $YEAR + 1900, 106 ); This will break if you analyze logs from the previous year. Change 102 my $YEAR = (localtime(time))[5]; # this is years since 1900 to 102 my $YEAR = (localtime($start))[5]; # this is years since 1900 or 102 my $YEAR = strftime("%Y", localtime($start)) - 1900; # this is years since 1900 which will extract the year from the argument to -s (or the default start timestamp.) Note that POSIX::strftime() is one of the most underutilized functions to ship with perl. Nine times out of ten, people write some convoluted code involving localtime(), arrays, and whatnot, all of which could be replaced with a single call to strftime(). hth, -- Bob ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdn _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk