Webalizer across multiple vhosts

Was looking for a way to get webalizer to include stats for all the vhosts on my server and cobbled together this script to run in cron…

cd $logloc
ls | egrep -v 'error|gz|sh|webalizer' | xargs cat > $file
ls | grep gz | egrep -v 'error|sh|webalizer' | xargs gunzip -c >> $file
echo "Sorting $fname"
sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $file > $file.sorted
echo "Runnig Webalizer"
webalizer 2> /dev/null
rm $file
rm $file.sorted
echo "Complete"
exit 0

This grabs data from all my vhost’s access.log files in my apache2 directory, concatenates them into one file, sorts it into date order, and then runs all of it through webalizer. It’s handy to see just how much punishment the web server is putting up with, and what is being accessed the most.

Oh, for this to work you have to setup webalizer with the following line of config config:

LogFile /var/log/apache2/webalizer.sorted

Leave a Reply

Your email address will not be published. Required fields are marked *