AWStats
AWStats copied to clipboard
calculated bandwidth doubles
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:
- Put awstats.test.conf in
/etc/awstats/
- Download the awstats-7.8 and place its extracted directory in the home directory.
- Make a folder in root, or modify the awstats.test.conf file to replace
/awstats-test
with your testing location. - Place the www.log file in the
awstats-test
directory. - Change directory into the
awstats-test
directory. - 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):
- OS: centos 7
- Browser N/A
- Version 7.8
Additional context Tested on perl v5.16.3 and v5.34.0
Attachments www.log awstats.test.conf