Ceci est une ancienne révision du document !


AWStats

AWStats est un anayleur de logs de serveur web. Il permet d'obtenir des rapports simples et efficaces sur la consultation d'un site Web.

Ce logiciel est utilisé dans le projet Projet Bender.

Installation

Paquets à installer :

  • awstats

Configuration

La configuration de awstats se trouve dans les fichiers /etc/awstats/awstats.conf et /etc/awstats/awstats.conf.local

Le premier paramètre à modifier est :

SiteDomain="matthieu.bouthors.org"

Si apache est configuré, le site devrait être disponible dans /cgi-bin/awstats.pl

Préparation des logs

Par défaut les logs ne sont pas lisibles pour le script, il faut les rendre accessibles par exemple en les attribuant à l'utilisateur www-data :

bender:~# cd /var/log/apache2
bender:/var/log/apache2# chown www-data *
bender:/var/log/apache2# ll
total 256
-rw-r----- 1 www-data adm  17304 2007-07-02 23:44 access.log
-rw-r----- 1 www-data adm 213032 2007-06-24 22:21 access.log.1
-rw-r----- 1 www-data adm   4348 2007-07-02 23:07 error.log
-rw-r----- 1 www-data adm   8684 2007-06-27 06:25 error.log.1
bender:/var/log/apache2#

Afin de rendre cela permanent, il faut modifier la configuration de logrotate dans /etc/logrotate.d/apache2 :

        create 640 www-data adm

Configuration de AWstats

Editer /etc/awstats/awstats.conf.local :

# You can overrides config directives here.
# This is particularly useful for users with several configs for
# different virtual servers, who want to reuse common parameters.
# Also, this file is not updated with each new upstream release.
SiteDomain="matthieu.bouthors.org"
HostAliases="localhost 127.0.0.1 REGEX[^.*mat\.homeftp\.org$]"
LogFile="/var/log/apache2/access.log"
LogFormat = 1
  • Cette configuration inclus le nom d'hote matthieu.bouthors.org ainsi que l'alias mat.homeftp.org.
  • Le fichier de log d'apache 2 est spécifié (par défaut awstats utilise apache 1.3).
  • “LogFormat = 1” indique le format de log par défaut utilisé par Apache2 (combined)

Remarque : awstats stocke ses données dans /var/lib/awstats/ par défaut.

Importer les logs manuellement

bender:~# cd /usr/lib/cgi-bin/
bender:/usr/lib/cgi-bin# su www-data
bender:/usr/lib/cgi-bin$ ./awstats.pl -config=awstats -LogFile=/var/log/apache2/access.log.1
Update for config "/etc/awstats/awstats.conf"
With data in log file "/var/log/apache2/access.log.1"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 831
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 831 new qualified records.
bender:/usr/lib/cgi-bin$ ./awstats.pl -config=awstats -LogFile=/var/log/apache2/access.log
Update for config "/etc/awstats/awstats.conf"
With data in log file "/var/log/apache2/access.log"...
Phase 1 : First bypass old records, searching new record...
Direct access to last remembered record is out of file.
So searching it from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 103
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 103 new qualified records.
bender:/usr/lib/cgi-bin$ exit
exit
bender:/usr/lib/cgi-bin#

Configurer l'automatisation

Le cron (/etc/cron.d/awstats) ajouté automatiquement doit être modifié ainsi pour apache 2 :

0,10,20,30,40,50 * * * * www-data [ -x /usr/lib/cgi-bin/awstats.pl -a -f /etc/awstats/awstats.conf -a -r /var/log/apache2/access.log ] && /usr/lib/cgi-bin/awstats.pl -config=awstats -update >/dev/null

Afin de ne pas perdre les logs lors de la rotation, il faut ajouter l'analyse en script dans la configuration de logrotate /etc/logrotate.d/apache2 :

        prerotate
                /usr/bin/sudo -u www-data /usr/lib/cgi-bin/awstats.pl -config=awstats -update
        endscript

Configurer Apache

Pour que les images s'affichent correctement il faut ajouter l'alias suivant :

Alias /awstats-icon/ /usr/share/awstats/icon/

Par exemple de cette façon :

  • créer le fichier /etc/apache2/sites-available/awstats avec le contenu suivant :
  Alias /awstats-icon/ /usr/share/awstats/icon/
  • puis l'activer :
# a2ensite awstats
Site awstats installed; run /etc/init.d/apache2 reload to enable.
# /etc/init.d/apache2 reload
Reloading web server config...7559
.
#

Backup

  • /etc/awstats/awstats.conf.local
  • /etc/logrotate.d/apache2
  • /var/lib/awstats/
  • /etc/cron.d/awstats
  • /etc/apache2/sites-available/awstats

Links

linux/awstats.1185825298.txt.gz · Dernière modification: 2009/07/22 21:31 (modification externe)
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki