eldy / AWStats

AWStats Log Analyzer project (official sources)
https://www.awstats.org
374 stars 120 forks source link

calculated bandwidth doubles #219

Open JamesColeman-LW opened 2 years ago

JamesColeman-LW commented 2 years ago

Describe the bug In reviewing some awstats reports, I noted that the bandwidth calculation was way off. After reviewing why, I isolated it to a single line with bandwidth of 359489526 bytes. I have attached an example anonymized log file which is able to reproduce this output.

To Reproduce Steps to reproduce the behavior:

  1. Put awstats.test.conf in /etc/awstats/
  2. Download the awstats-7.8 and place its extracted directory in the home directory.
  3. Make a folder in root, or modify the awstats.test.conf file to replace /awstats-test with your testing location.
  4. Place the www.log file in the awstats-test directory.
  5. Change directory into the awstats-test directory.
  6. Run the following commands:
    perl ~/awstats-7.8/wwwroot/cgi-bin/awstats.pl -config=test -year=2022  -month=02 --update
    echo -n "perl calc: "
    cat www.log | perl -e 'my $sum=0; while(<>) { my ($traffic) = m/\[.+\] ".+" \d+ (\d+)/; $sum += $traffic}; print "$sum\n"'
    echo -n "awstats calc: "
    grep -E "^# Date" -A2 awstats022022.test.txt | tail -n 1 | awk '{print $4}'

Expected behavior Calculated bandwidth to equal 359489573 which is the sum of the log lines.

Desktop (please complete the following information):

Additional context Tested on perl v5.16.3 and v5.34.0

Attachments www.log awstats.test.conf