instalace awstats (generovani offline)



apt-get install awstats
cp /etc/awstats/awstats.conf /etc/awstats/awstats.domena.cz.conf
v novém .conf souboru stačí editovat 2 promenne:
SiteDomain = domena.cz
LogFormat = 1
LogFile = "/var/log/apache2/domena.cz-access.log"
Pokud mame logrotate a chceme importovat do statistik i starsi logy, napiseme si parser vsech logu a LogFile docasne zmenime na vystup parseru:
LogFile="/usr/local/bin/awstats-parse-logs domena.cz |"

cat /usr/local/bin/awstats-parse-logs

#!/bin/bash
if [ "$1" = "" ]; then
    echo "Usage: $0 domain.com"
    exit
fi

dir=/var/log/apache2
year=´date +%Y´
month=´date +%-m´

for i in ´seq 0 23´;
do
    j=$((25-$i))
    gzip -d < $dir/$1-access.log.$j.gz
done
Pokud chceme vygenerovat zpetne pro vic domen, mesicu a roku statistiky, viz skript:
#!/bin/bash

script=/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl
prog=/usr/lib/cgi-bin/awstats.pl
dir=/var/www/html/domena.cz/stats

# seznam domen
dom=('domena.cz')

for (( i = 0 ; i < ${#dom[@]} ; i++ ));
do
    if [ ! -d $dir ] ; then
        mkdir -p $dir
    fi

    for (( year = 2007 ; year < 2008 ; year++ ));
    do
        if [ ! -d $dir/$year ] ; then
            mkdir -p $dir/$year
        fi

        for (( month = 1 ; month <= 12 ; month++ ));
        do
            if [ ! -d $dir/$year/$month ] ; then
                mkdir -p $dir/$year/$month
            fi

            $script -awstatsprog=$prog -config=${dom[$i]} -update -lang=cz -year=$year -month=$month -dir=$dir/$year/$month
        done
    done
done
Last update:
2008-01-17 11:24
Author:
Daniel
Revision:
1.41
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.