Plesk generates web statistics using awstats. The "Select Period" drop down box is created with all the month dates in a random order which is not very helpful! It makes selecting the month you want tricky.
The following code checks which domains are using awstats and will re-jig their nav.html
files to put them all in the correct order. Place the following program into your cron to run after awstats has completed.
The simplest way to find out when awstats completes, is to check the creation time of the nav.html
file and add 30 minutes to be safe.
I've called mine: **plesk-awstats-nav-fixer.sh**
#!/bin/bash
#
# This code was written by BigSoft Limited.
# Please include this message when you use the code in any form.
# Code comes as is and without warrenty
#
# David Newcomb (c) BigSoft Limited 2008
#
# Get MySQL's admin password
PSA_PW=`cat /etc/psa/.psa.shadow`
PSA_USER=admin
# Location of webstats folders
VHOST=/var/www/vhosts
STATS=statistics/webstat
# Find enabled domain names that use awstats statistics.
# When a client is deactivated the status of a domain
# becomes non-zero, so there is no need to join on the
# client's table.
SQL=" SELECT d.name"
SQL="$SQL FROM domains d, hosting h"
SQL="$SQL WHERE d.id = h.dom_id"
SQL="$SQL AND d.status = 0"
SQL="$SQL AND h.webstat = 'awstats'"
# Run SQL
DOMAINS=`mysql --skip-column-names -u$PSA_USER -p$PSA_PW -e"$SQL" psa`
for DOMAIN in $DOMAINS
do
AWSTATS_DIR=$VHOST/$DOMAIN/$STATS
echo "Checking $AWSTATS_DIR"
if [ ! -d "$AWSTATS_DIR" ]
then
echo "Sorry awstats folder does not exist: $AWSTATS_DIR"
continue
fi
cd $AWSTATS_DIR
grep '^<option value="' nav.html | sort -r > nav_options.html
grep -v '<option value="' nav.html > nav_nooptions.html
ed nav_nooptions.html << EOF
/^<\/select>
-1r nav_options.html
wq
EOF
rm -f nav_options.html
rm -f nav.html
mv nav_nooptions.html nav.html
done
You have to love ed! It is (as far as I know) the only editor that is described as WYGIWYG (What You Get Is What You Get - wikipedia deleted my entry because no one else seems to have heard of this expression apart from me!).
This is the second problem with Plesk and awstats I have documented. Here's another: Plesk Awstat forgets the monthly statistics.