AWSTATS

Awstats est un analyseur de log permettant d’afficher des statistiques sous forme de tableaux et graphiques.

Installation

Plutôt que d’utiliser les paquets, il vaut mieux récupérer l’application directement sur le site Internet pour avoir la dernière version.

cd /tmp
wget http://prdownloads.sourceforge.net/awstats/awstats-6.7.tar.gz
tar xzf awstats-6.7.tar.gz
mkdir /usr/local/awstats
mv /tmp/awstats-6.7 /usr/local/awstats
cd /usr/local/awstats

Exécution du script d’installation :

perl /usr/local/awstats/tools/awstats_configure.pl

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path ('none' to skip web server setup):
> /usr/local/apache2/conf/httpd.conf
- This file does not exists.
Config file path ('none' to skip web server setup):
> /etc/apache2/httpd.conf

-----> Check and complete web server config file '/etc/apache2/httpd.conf'

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

Je mets « y » pour créer un fichier de configuration pour un site. En effet, AWSTATS utilise 1 fichier de configuration pour 1 site.

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.lespotes.org

Il faut spécifier le nom du site pour lequel nous allons analyser les logs. J’utilise un domaine que j’héberge : www.lespotes.org.

-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):

Il faut appuyer directement sur la touche « Entrée » en ne changeant rien car je souhaite stocker le fichier de configuration directement dans le dossier « /etc/awstats« .

-----> Create config file '/etc/awstats/awstats.www.lespotes.org.conf'
Config file /etc/awstats/awstats.www.lespotes.org.conf created.

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.lespotes.org
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.www.lespotes.org.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.lespotes.org' with command:
> perl awstats.pl -update -config=www.lespotes.org
You can also read your statistics for 'www.lespotes.org' with URL:
> http://localhost/awstats/awstats.pl?config=www.lespotes.org

Press ENTER to finish...

Le script nous informe sur le fait qu’il n’a pas pû rajouter une tâche CRON donc il faudra le faire.

Stockage des fichiers de log

Les logs de Awstats seront stockés dans « /var/log/awstats« , donc il faut créer le dossier :

mkdir /var/log/awstats

AWSTATS va utiliser ce dossier pour mémoriser les endroits qu’il a déja analysé dans les logs d’Apache2 pour éviter de repasser sur les lignes déjà traitées.

Configuration d’Apache2

Pour la bonne analyse des logs, je sépare les logs de chaque site pour éviter d’avoir toutes les logs dans le même fichier. Il faut rajouter 2 paramètres dans le VirtualHost pour les logs :

<VirtualHost *>

[...]

ErrorLog /var/log/apache2/lespotes_error.log
LogLevel warn

CustomLog /var/log/apache2/lespotes_access.log combined
</VirtualHost>

Puis :

/etc/init.d/apache2 reload

Configuration pour le domaine

Il faut ensuite configurer le fichier de configuration pour le site que nous souhaitons analyser avec AWSTATS :

nano /etc/awstats/awstats.www.lespotes.org.conf

LogFile="/var/log/apache2/lespotes_access.log"
DirData="/var/log/awstats"
DNSLookup=1

DNSLookup va convertir l’IP en nom de domaine ce qui sera plus lisible.

Exécution des mises à jours

AWSTATS va lire chaque ligne de log et générer un fichier de statistiques. Voici la ligne à exécuter pour chaque site analysé :

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.lespotes.org

Voici le résultat de l’exécution de awstats.pl :

Create/Update database for config "/etc/awstats/awstats.www.lespotes.org.conf" by AWStats version 6.7 (build 1.892)
From data in log file "/var/log/apache2/lespotes_access.log"...
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: 8522
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 8522 new qualified records.

Création des pages HTML

Une fois les fichiers de log parsés, AWSTATS peut générer des fichiers HTML permettant l’affichage dans un navigateur Internet. Voici la ligne à exécuter :

/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=www.lespotes.org -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -dir=/var/www/dossier_admin/awstats/

* -config=xxxxx -> spécifie le site à analyser * -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -> spécifie l’emplacement du script awstats.pl * -dir=/var/www/dossier_admin/awstats/ -> spécifie le fichier où vont se trouver les fichiers HTML générés

Voici le résultat de cette ligne de commande :

Build main page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output
Build alldomains page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=alldomains
Build allhosts page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=allhosts
Build lasthosts page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=lasthosts
Build unknownip page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=unknownip
Build allrobots page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=allrobots
Build lastrobots page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=lastrobots
Build session page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=session
Build urldetail page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=urldetail
Build urlentry page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=urlentry
Build urlexit page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=urlexit
Build osdetail page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=osdetail
Build unknownos page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=unknownos
Build browserdetail page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=browserdetail
Build unknownbrowser page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=unknownbrowser
Build refererse page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=refererse
Build refererpages page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=refererpages
Build keyphrases page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=keyphrases
Build keywords page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=keywords
Build errors404 page: "/usr/local/awstats/wwwroot/cgi-bin/awstats.pl" -config=www.lespotes.org -staticlinks -output=errors404
20 files built.
Main HTML page is 'awstats.www.lespotes.org.html'.

Affichage des icônes

Il est possible que les icônes ne s’affichent pas car les pages HTML font appel à des liens absolus, donc il faut créer un line symbolique :

ln -s /usr/local/awstats/wwwroot/icon/ /var/www/

Tâche CRON

Pour automatiser cette tâche, il faut paramétrer CRON. Un script va parser les logs puis générer les pages HTML :

nano /etc/awstats/mise_jour.sh

#!/bin/sh
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.lespotes.org
/usr/local/awstats/tools/awstats_buildstaticpages.pl -config=www.lespotes.org -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -dir=/var/www/dossier_admin/awstats/

chmod +x /etc/awstats/mise_jour.sh

Automatisation du script pour être exécuté tous les matins à 1h30 :

crontab –e
30 01 * * * /etc/awstats/mise_jour.sh

/etc/init.d/cron restart
zoloft versus generic zoloft buy buy zoloft amoxil cost order Amoxicillin purchase amoxil buy amoxicillin in canada atarax for bladder spasms what is... cheap atarax Buying Online Hydroxyzine | Buy Medication Without Prescription from Indian Pharmacy. dapoxetine vs paroxetine dapoxetine with alcohol dapoxetine bluelight dapoxetine online

Plan du site