The site cut out some of the crontab and script, …

Tuesday, 16th April 2024

Comment on Generate Awstats Statistics from multiple Apache logs / Generate Awstats statistics for multiple domain names / Automatically configure awstats to show reports for multiple domain names by Clock.

the site cut out some of the crontab and script, will post to another site and make link sometime.

Clock Also Commented

Generate Awstats Statistics from multiple Apache logs / Generate Awstats statistics for multiple domain names / Automatically configure awstats to show reports for multiple domain names
I modified your script so I would not have to setup individual logs for each site as they are dynamically created using aegir.

1.Setup cron (run crontab -e or add a file in /etc/cron.d)
# split access.log into domainlogs/domainname.log
5,15,25,35,45,55 * * * * root cd /var/log/apache2/domainlogs; /usr/sbin/split-logfile /dev/null

2.Create script file (nano /usr/lib/cgi-bin/my.sh)
loop_dir=/var/log/apache2/domainlogs;
index_page=/var/www/test.html;
title=”ESSDACK.org Statistics”;
css_file=”style.css”;
awstats_location=”/usr/lib/cgi-bin/awstats.pl”;
awstats_conf=”/etc/awstats/awstats.conf”;
awstats_url=”http://stats.goosewing.essdack.org/statistics/awstats.pl?config”;
# create an empty page
cat /dev/null > $index_page;
# add html tags to top of page
echo “$title
$title” >> $index_page;
echo “” >> $index_page;
echo “Awstats web statistics for:” >> $index_page;

# find all domains by log file
for i in $(echo $loop_dir/*); do
# check that its a file and not a dir -f (http://www.linuxtutorialblog.com/post/tutorial-conditions-in-bash-scripting-if-statements#file-based-conditions)
if [ -f “$i” ]; then
filename=$(basename $i);
extension=${filename##*.}
domain_name=${filename%.*}

#echo “full path = $i; filename = $filename; extension = $extension; domain = $domain”;
echo “Generating Awstats file for: $domain_name”;
# create /etc/awstats/awstats.$domain.conf file
sed -e “s#SiteDomain=””#SiteDomain=”$domain_name”#g” -e “s#LogFile=””#LogFile=”$i”#g” $awstats_conf > /etc/awstats/awstats.”$domain_name”.conf;
[ -x $awstats_location -a -f $awstats_conf -a -r $i ] && $awstats_location -config=awstats -update >/dev/null
# run sudo /usr/lib/cgi-bin/awstats.pl -config=$domain -update
[ -x $awstats_location -a -f /etc/awstats/awstats.”$domain_name”.conf -a -r $i ] && $awstats_location -config=”$domain_name” -update
# add links for web sites stat page
echo “ $domain_name ” >> $index_page;
fi
done

# add html tags to bottom of page
echo “” >> $index_page;

3.set permissions on file (chmod 755 /user/lib/cgi-bin/my.sh
4. have fun


Share this on:

Comments are closed.