Question
How to recalculate AWStats web-statistics using domain logs for previous months?
Answer
There are two techniques to recalculate/regenerate AWStats statistic files:
-
From AWStats txt files, which are still within the AWStat directory:
Instructions to check
-
Connect to the server via SSH.
-
Check the directory:
# ls -lahn /var/www/vhosts/system/example.com/statistics/webstat-ssl/ | grep awstats | awk ‘{print $9}’
awstats082018.example.com-https.txt
awstats092018.example.com-https.txt
awstats102018.example.com-https.txt
awstats112018.example.com-https.txt
awstats122018.example.com-https.txt
Note: In this case the months 08(August), 09(Semptember), 10(November), 11(October), 12(December) can be retrieved for the year 2018.
-
-
From the old logs, which are present on the server.
Note: In both, old logs and AWStats txt file, are deleted, the recalculation will not be possible.
Installation
How to install the tool
-
Connect to a Plesk server via SSH.
-
Download and unpack the script:
# wget https://support.plesk.com/hc/en-us/article_attachments/360015808219/rebuild_awstats.tar.gz
# tar -xzvf rebuild_awstats.tar.gz
-
For Ubuntu 14.04, a symbolic link should be created:
# ln -s /usr/lib/plesk-9.0/logresolvemerge /usr/share/doc/awstats/examples/logresolvemerge.pl
-
-
Run this command to show help message:
# ./rebuild_awstats.sh
Rebuild AWstats static pages from available log files.Usage: ./rebuild_awstats.sh [options] [<domains…>]
Options:
-A
–all-domains
Process all domains. If this option is not specified, then list of
domains to process must be provided.-F
–from-scratch
Remove contents of webstat/ and webstat-ssl/ directories before
rebuilding statistics pages (originals are saved with numeric
suffix). Statistics will be rebuilt from logs only, only for
period covered by log files. If this parameter is not used, then
statistics is recalculated beginning on the month on which log files
start (if log starts in the middle of the month, then statistics
for first half of the month will not be present.)-R
–rebuild
Rebuilds the HTML files for AWStats.-h
–help
This message.
Click on a section to expand
How script works
-
General Functionality
-
For each specified domain (or all domains, if the -A option is used), the script will memorize the log file’s start date.
-
Then, it will remove AWStats data files for the months covered by the log files and rebuild them with corresponding information.
-
Finally, the script will build static pages with statistics summary for each month covered by the log files.
-
-
-F
If the -F option is used, all AWStats data will be removed and new files will be generated using only the information stored in the log files. -
-R
if the -R option is used, the script will gather all data of the mentioned domain and will generate all months, where the AWStats txt data is existing. -
Merging Web-Statistics
In order to merge web-statistics which was created from scratch with…