Cobra Forum

Plesk Panel => Plesk Service/Interface => Topic started by: mahesh on Jan 02, 2024, 05:41 AM

Title: Unable to recalculate Plesk AWStats and rotate its log file:
Post by: mahesh on Jan 02, 2024, 05:41 AM
Question:
Unable to recalculate Plesk AWStats and rotate its log file: your log file must have a bad format or LogFormat parameter setup does not match this format
Symptoms
#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] "\x15\x03\x00\x00\x02\x01\x00" 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).
Cause
Product issue:

Resolution
Please consider updating your server:
How to install Plesk updates
Workaround
If update is not possible for some reason you may try the following
workaround
1.Connect to the server via SSH
2.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:
Quote203.0.113.2 - - [28/Oct/2017:09:10:31 +0900] "\x15\x03\x00\x00\x02\x01\x00" 400 166 "-" "-"
The correct format would be:

Quote203.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)"
3.Recalculate statistics again:
#plesk sbin statistics --calculate-one --domain-name=example.com