Log rotation is not functioning properly on this server for the access_log.processed files.
It fails with the following error:
# /usr/local/psa/admin/sbin/statistics --calculate-all
WARNING during statistics_collector execution: : statistics_collector: cannot seek /var/www/vhosts/test.com/statistics/logs/access_log.processed at required position: Invalid argument
System error 22: Invalid argument
The issue may occur if a log file of one of the domains is too large for the statistics script to process it in the current environment.
You may find the largest log file with this command:
# du -s /var/www/vhosts/*/statistics/logs/*.processed* | sort -n
The last file in the output will be the largest. Double-check its size:
# du -sh /var/www/vhosts/test.com/statistics/logs/access_log.processed
If it is larger than 1 GB, it is most likely causing statistics to fail.
The problem usually occurs only on 32-bit systems, so in the long term, the best option would be to upgrade to a 64-bit environment.
Right now, we can split the file into smaller parts and have the statistics process those parts one-by-one. Follow these steps, assuming the problem domain name is "test.com":
# cd /var/www/vhosts/test.com/statistics/logs/
# split --line-bytes=1024m access_log.processed access_log.processed
You will get several small files like these:
Move the original access_log.processed file to a safe location, just in case:
# mkdir /root/log_backup
# mv access_log.processed /root/log_backup
Now we need to process each of the small files using the statistics utility:
Rename the first file to access_log.processed and launch statistics recalculation for the affected domain:
# mv access_log.processedaa access_log.processed
# /usr/local/psa/admin/bin/statistics --calculate-one --domain-name=test.com
Then do the same for the rest of the small files, one-by-one. Once you complete all the steps, the statistics for the domain should become correct and its recalculation should stop failing.
To avoid the issue in the future, check your log rotation settings and make sure they are set to rotate log files by size, not by time.
In rare cases, if the minimum log rotation period, which is 1 day, is too long for you, you may create a cron job that will run every several hours and check statistics log file sizes, splitting them if necessary.