Symptoms
- Unable to recalculate Awstats statistics in Plesk:
# plesk sbin statistics –calculate-one –domain-name=example.com
Webstat: awstats
Executing awstats…
Execution of /var/www/cgi-bin/awstats/awstats.pl -update -configdir=/usr/local/psa/etc/awstats -config=example.com-https -LogFile=/var/www/vhosts/system/example.com/logs/access_ssl_log.webstat failed with return code 1.
Stdout is
Create/Update database for config “/usr/local/psa/etc/awstats/awstats.example.com-https.conf” by AWStats version 7.4 (build 20150714)
From data in log file “/var/www/vhosts/system/example.com/logs/access_ssl_log.webstat”…
Phase 1 : First bypass old records, searching new record…
Direct access to last remembered record has fallen on another record.
So searching new records from beginning of log file…
AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.
Your log file /var/www/vhosts/system/example.com/logs/access_ssl_log.webstat must have a bad format or LogFormat parameter setup does not match this format.
Your AWStats LogFormat parameter is:
1
This means each line in your web server log file need to have “combined log format” like this:
203.0.113.1 – – [10/Jan/2001:02:14:14 +0200] “GET / HTTP/1.1” 200 1234 “http://www.fromserver.com/from.htm” “Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)”
And this is an example of records AWStats found in your log file (the record number 50 in your log):
203.0.113.2 – – [28/Oct/2017:09:10:31 +0900] “x15x03x00x00x02x01x00” 400 166 “-” “-“
Setup (‘/usr/local/psa/etc/awstats/awstats.example.com-https.conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).
- The
access_ssl_log.webstat
log file is not rotated. As a result, Awstats webstat page shows 0 values (statistics is empty), while in fact domain’s access_log contains entries.
Cause
Incorrectly formatted lines in access_ssl_log.webstat
file cannot be parsed by AWStats.
The fact that warnings about that are not sent is a Plesk bug with ID #PPPM-9832 which is planned to be fixed in future products updates.
Resolution
- Connect to the server via SSH
- Open the file from the error message (
/var/www/vhosts/system/example.com/logs/access_ssl_log.webstat
) in any text editor, and remove incorrectly formatted lines like:203.0.113.2 - - [28/Oct/2017:09:10:31 +0900] "x15x03x00x00x02x01x00" 400 166 "-" "-"
The correct format would be:
203.0.113.1 - - [10/Jan/2001:02:14:14 +0200] "GET / HTTP/1.1" 200 1234 "http://www.fromserver.com/from.htm" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
- Recalculate statistics again:
# plesk sbin statistics –calculate-one –domain-name=example.com