Run the below commands to download, unzip, make executable, and execute the script on your server:
# wget http://kb.parallels.com/Attachments/kcs-10115/rebuild_awstats.zip # unzip rebuild_awstats.zip # chmod u+x rebuild_awstats.sh # ./rebuild_awstats.sh
It will display "Help" if no arguments or options are supplied. See more information below to understand how the script works.
For each specified domain (or for all domains if the -A option used), learn the log files' start date. Remove AWstats data files for months covered by the log file and rebuild them with information from the logs. Then build static pages with a statistics summary for every month covered by the log files.
Alternatively, if the -F option is used, then all data files are removed and new files are generated using information from the log files.
# ./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.) -h --help This message. Home page: <http://kb.parallels.com/en/115476>
For each processed domain, the script reports the following:
=== pp11.plesk.ru Saving: webstat* --> webstat*.9 Logs begin on Oct 27 2012 access_log* (new/old/corrupted): 9/0/0 access_ssl_log* (new/old/corrupted): 71/0/0 Rebuilding static pages: 2012-10 2012-11 2012-12 2013-01 2013-02
As you can see, it saves the original directories with a numeric suffix (the suffix is increased if the destination directory already exists), so it is possible to roll-back to a previous version if needed.
rebuild_awstats.sh script fails with error:
"ERROR: failed to merge access_log"