Search

Search for:
Language:  

No categories for selected product

How to recalculate AWstats statistics from logs from previous months?

Article ID: 5550 
Last Review: Apr, 16 2012
Views:
APPLIES TO:
  • Parallels Plesk Panel 10.x for Linux
  • Parallels Plesk Panel 9.x for Linux/Unix
  • Parallels Plesk Panel 8.x for Linux/Unix

Resolution

Plesk statistics utility does not use info from the log records of the previous months and only builds AWstats pages for the current month. In order to rebuild AWstats pages for previous periods, follow these steps:

0. Define these environment variables according to requirements:

Set the needed domain name

export vhost_name=<DOMAIN NAME>

Set other variables:

export AWSTATS_BIN_D=`grep ^AWSTATS_BIN_D /etc/psa/psa.conf | awk '{print $2}'`
export HTTPD_VHOSTS_D=`grep ^HTTPD_VHOSTS_D /etc/psa/psa.conf | awk '{print $2}'`
export PRODUCT_ROOT_D=`grep ^PRODUCT_ROOT_D /etc/psa/psa.conf | awk '{print $2}'`
export awstats=${AWSTATS_BIN_D}/awstats.pl
export awstats_gen_opts="-staticlinks -configdir=${PRODUCT_ROOT_D}/etc/awstats -config=${vhost_name}-http"

export awstats_gen_opts_ssl="-staticlinks -configdir=${PRODUCT_ROOT_D}/etc/awstats -config=${vhost_name}-https"  

1. Check if directories $vhost_name/statistics/webstat and $vhost_name/statistics/webstat-ssl contain *.txt files with the information from previous periods. Skip to step #4 if you wish to use these data during the AWstats page rebuild.

2. Rename *.txt files from the directories:

find $HTTPD_VHOSTS_D/$vhost_name/statistics/webstat -name '*.txt' -exec mv '{}' '{}'.orig \;
find $HTTPD_VHOSTS_D/$vhost_name/statistics/webstat-ssl -name '*.txt' -exec mv '{}' '{}'.orig \;

3. Analyze access to the log file with the information from previous periods by awstats:

$awstats $awstats_gen_opts -LogFile=$HTTPD_VHOSTS_D/${vhost_name}/statistics/logs/access_log.processed
$awstats $awstats_gen_opts_ssl -LogFile=$HTTPD_VHOSTS_D/${vhost_name}/statistics/logs/access_ssl_log.processed

If multiple log files are to be re-processed, start from the oldest one.

4.  Create appropriate (in format 'YYYY-MM') directories hierarchy for the period covered by the log files to be processed in the $vhost_name/statistics/webstat directory:

for y in 2007 2008 ; do for m in 1 2 3 4 5 6 7 8 9 10 11 12 ; do mkdir ${HTTPD_VHOSTS_D}/${vhost_name}/statistics/webstat/$y-$(printf "%.2d" $m) ; done ; done
for y in 2007 2008 ; do for m in 1 2 3 4 5 6 7 8 9 10 11 12 ; do mkdir ${HTTPD_VHOSTS_D}/${vhost_name}/statistics/webstat-ssl/$y-$(printf "%.2d" $m) ; done ; done

NOTE: put required years instead of 2007 2008 and month instead of 1 2 3 4 5 6 7 8 9 10 11 12 in the commands above.

5. Run the following cycle to rebuild AWstats pages.

For HTTP statistics:

for y in 2007 2008 ; do \
 for m in 1 2 3 4 5 6 7 8 9 10 11 12 ; do \
     dest_dir=$HTTPD_VHOSTS_D/$vhost_name/statistics/webstat/$y-$(printf "%.2d" $m) ; \
     $awstats $awstats_gen_opts -month=$m -year=$y -output > $dest_dir/awstats.${vhost_name}-http.html ; \
     ln -s $dest_dir/awstats.${vhost_name}-http.html $dest_dir/index.html ; \
     for output in alldomains allhosts lasthosts unknownip allrobots lastrobots session urldetail urlentry urlexit osdetail unknownos refererse refererpages keyphrases keywords errors404 ; do \
         $awstats $awstats_gen_opts -month=$m -year=$y -output=$output > $dest_dir/awstats.${vhost_name}-http.$output.html ; \
     done ; \
 done ; \
done


For HTTPS statistics:

for y in 2007 2008 ; do \
 for m in 1 2 3 4 5 6 7 8 9 10 11 12 ; do \
     dest_dir=$HTTPD_VHOSTS_D/$vhost_name/statistics/webstat-ssl/$y-$(printf "%.2d" $m) ; \
     $awstats $awstats_gen_opts_ssl -month=$m -year=$y -output > $dest_dir/awstats.${vhost_name}-https.html ; \
     ln -s $dest_dir/awstats.${vhost_name}-https.html $dest_dir/index.html ; \
     for output in alldomains allhosts lasthosts unknownip allrobots lastrobots session urldetail urlentry urlexit osdetail unknownos refererse refererpages keyphrases keywords errors404 ; do \
         $awstats $awstats_gen_opts_ssl -month=$m -year=$y -output=$output > $dest_dir/awstats.${vhost_name}-https.$output.html ; \
     done ; \
 done ; \
done

 
NOTE: put required years instead of 2007 2008 and month instead of 1 2 3 4 5 6 7 8 9 10 11 12 in the commands above.

6. Run the statistics command to update the upper frame navigation menu with the month listing:

$PRODUCT_ROOT_D/admin/sbin/statistics --calculate-one --domain-name=$vhost_name

Additional information

HTTP statistics is available at https://DOMAIN NAME>/plesk-stat/webstat.
HTTPS statistics is available at https://DOMAIN NAME>/plesk-stat/webstat-ssl





Email subscription for changes to this article Email subscription for changes to this article

Please provide feedback on this article

* Did this article help you solve your issue?
Yes
No
What can we do to improve this article?

PLEASE NOTE: Knowledge Base feedback is reviewed occasionally and we do not reply to most of the individual comments. Please contact us using one of the Support channels for a response to any support inquiries. We appreciate your feedback.

Subscribe me for article updates. My email
 
 
 
 
 
 
For Home
For Hosters
For SaaS
For IaaS
For Developers
For Health Care
 
Desktop Virtualization
- Parallels Desktop 7 for Mac
- Parallels Transporter
- Parallels Mobile
- Parallels Desktop Switch to Mac Edition
- Parallels Workstation
- Parallels Workstation Extreme
- Parallels Desktop for Mac Enterprise Edition
Server Virtualization
- Parallels Server for Mac 4.0
- Parallels Server for Mac 4.0 Mac mini Edition
- Parallels Server for Mac Bare Metal Edition
- Parallels Server Bare Metal
- Parallels Virtuozzo Containers
Automation
- Parallels Operations Automation
- Parallels Automation for Cloud Infrastructure
- Parallels Business Automation
- Parallels Business Automation Standard
- Parallels Virtual Automation
- Parallels Plesk Panel Suite
- Parallels Small Business Panel
- Parallels Domain/SSL Reseller Program
- Parallels Partner Storefront
More Products