6

Click here to load reader

Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

Embed Size (px)

Citation preview

Page 1: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 1/6

POMENTE GUILLAUMELe partage, un esprits sans limites…

INSTALLATION ANALYSEUR DE LOG PROXYSQUID AVEC AWSTATS

Publié le Lundi, novembre 19th, 2012 by in Debian, guillaume pomente, Linux, POMENTE

Guillaume, Tuto / Howto / tutorial with Pas de commentaires

La solution proxy squid produit des fichiers logs qu’il est intéressant de regarder via une

interface web. Voici comment mettre en place un analyseur de fichiers log pour squid

avec AWSTATs.

1 – Installation d’Apache

Awstat génère des pages web, il est donc nécessaire d’installer un serveur http. Dans

mon cas je vais utiliser Apache.

aptitude install apache2

2 – Installation d’AWSTATs

AWStats est un outils gratuits qui permet d’analyser des fichiers LOGs en les

retranscrivant sous forme de pages web

aptitude install awstats

Création des dossier wwwroot et cgibin

mkdir /usr/share/doc/awstats/examples/wwwroot

mkdir /usr/share/doc/awstats/examples/wwwroot/cgi-bin

Extraction du fichier de configuration

cd /usr/share/doc/awstats/examples/

gzip -d /usr/share/doc/awstats/examples/awstats.model.conf.gz

Copie du fichier de configuration

cp /usr/share/doc/awstats/examples/awstats.model.conf

/usr/share/doc/awstats/examples/wwwroot/cgi-bin/

Execution du script de configuration

cd /usr/share/doc/awstats/examples/

perl awstats_configure.pl

Recherche

ARTICLES RÉCENTS

INSTALLATION

CONFIGURATION LINSHARE

AVEC LIAISON LDAP ou

ACTIVE DIRECTORY SUR

DEBIAN

INSTALLATION ET

CONFIGURATION TERMINAL

SERVEUR – APPREMOTE SUR

WINDOWS 2008 R2

DEPOT POUR DEBIAN WHEEZY

TUTO SERVEUR CALENDRIER

AVEC DAVICAL ET AGENDAV

SOUS DEBIAN

IMPRESSION EN BOUCLE SUR

IMPRIMANTE LOCALE

Accueil Contact À propos

INSTALLATION CONFIGURATION LINSHARE AVEC LIAISON LDAP ou ACTIVE DIRECTORY SUR DEBIAN

LinShare est une application de partage de fichiers sécurisé libre et gratuite,

développée et distribuée par l'entreprise Linagora selon les méthodes de

développement du logiciel libre/open source. LinShare permet la mise en place

[more]

zimbra

windows

windows 7

web 2.0

vmware server

vmwareutilisateur

squidguard

synchronisation

tuto

Ubuntu

squidsqueeze

serveur 2008

serveurscript

pomente

POMENTE

Guillaume

powershell

R2sauvegarde zimbra

NTPmysqlMicrosoft

installation

how toguillaumeGLPI

désactiver

erreur

ESXi

esxi 4.1

Debiancreation

configuration

automatique

2008 R2

active

directory

ajout

2008

• • •

Page 2: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 2/6

—– AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur —–

This tool will help you to configure AWStats to analyze statistics for

one web server. You can try to use it to let it do all that is possible

in AWStats setup, however following the step by step manual setup

documentation (docs/index.html) is often a better idea. Above all if:

- You are not an administrator user,

- You want to analyze downloaded log files without web server,

- You want to analyze mail or ftp log files instead of web log files,

- You need to analyze load balanced servers log files,

- You want to ‘understand’ all possible ways to use AWStats…

Read the AWStats documentation (docs/index.html).

—–> Running OS detected: Linux, BSD or Unix

Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.

If you want to use standard directory, you should first move all content

of AWStats distribution from current directory:

/usr/share/doc/awstats/examples

to standard directory:

/usr/local/awstats

And then, run configure.pl from this location.

Do you want to continue setup from this NON standard directory [yN] ? Y

—–> 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 files\apache group\apache\conf\httpd.conf

Config file path (‘none’ to skip web server setup):

> /etc/apache2/apache2.conf

—–> Check and complete web server config file ‘/etc/apache2/apache2.conf’

Add ‘Alias /awstatsclasses « /usr/share/doc/awstats/examples/wwwroot/classes/ »‘

Add ‘Alias /awstatscss « /usr/share/doc/awstats/examples/wwwroot/css/ »‘

Add ‘Alias /awstatsicons « /usr/share/doc/awstats/examples/wwwroot/icon/ »‘

Page 3: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 3/6

Add ‘ScriptAlias /awstats/ « /usr/share/doc/awstats/examples/wwwroot/cgi-bin/ »‘

Add ‘<Directory>’ directive

AWStats directives added to Apache config file.

—–> Update model config file ‘/usr/share/doc/awstats/examples/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

—–> 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:

> NOMDEVOTRESERVEURSQUID

—–> 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):

>[ENTRÉE]

A SIMPLE config file has been created: /etc/awstats/awstats.SrvProxy.conf

You should have a look inside to check and change manually main parameters.

You can then manually update your statistics for ‘SrvProxy’ with command:

> perl awstats.pl -update -config=SrvProxy

You can also read your statistics for ‘SrvProxy’ with URL:

> http://localhost/awstats/awstats.pl?config=SrvProxy

Press ENTER to finish…

[ENTRÉE]

Page 4: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 4/6

Editer le fichier de configuration

nano /etc/awstats/awstats.NOMDEVOTRESERVEURSQUID.conf

Modifier les lignes suivantes :

LogFile= »/var/log/squid/access.log »

LogFormat= »%host %other %logname %time1 %methodurl %code %bytesd %other »

SiteDomain= »NOMDEVOTRESERVEURSQUID »

2-1 Configuration de Squid pour AWSTATs

nano /etc/squid/squid.conf

Ajouter les lignes suivantes avant les ACLs

# Configuration pour AWStats

logformat full %>a %ui %un [%{%d/%b/%Y:%H:%M:%S +0000}tl] « %rm %ru HTTP/%rv » %Hs

%<st « %{Referer}>h » « %{User-Agent}>h » « - » %tr %{Host}>h

access_log /var/log/squid/access.log full

Redémarrer Squid

/etc/init.d/squid restart

Générer les premieres statistiques

/usr/lib/cgi-bin/awstats.pl -config=NOMDEVOTRESERVEURSQUID –update

/!\ Si votre serveur Squid a déjà générer les logs, vous allez surement avoir des erreurs

au lancement de la commande /!\

Exemple d’erreurs :

Create/Update database for config

« /etc/awstats/awstats.NOMDEVOTRESERVEURSQUID.conf » by A WStats version 6.95

(build 1.943)

From data in log file « /var/log/squid/access.log »…

Phase 1 : First bypass old records, searching new record…

Searching new records from beginning of log file…

AWStats did not find any valid log lines that match your LogFormat paramete r, in the

50th first non commented lines read of your log.

Your log file /var/log/squid/access.log must have a bad format or LogFormat parameter

setup does not match this format.

Your AWStats LogFormat parameter is:

%host %other %logname %time1 %methodurl %code %bytesd %other

This means each line in your web server log file need to have the following personalized

log format:

%host %other %logname %time1 %methodurl %code %bytesd %other

And this is an example of records AWStats found in your log file (the recor d number 50

in your log):

1555482948.360 140 ip.client TCP_MISS/504 1585 GET http://site.com/ –

Page 5: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 5/6

DIRECT/127.0.0.1 text/html

Setup (‘/etc/awstats/awstats.NOMDEVOTRESERVEURSQUID.conf’ file, web server or

permissions ) may be wrong.

Check config file, permissions and AWStats documentation (in ‘docs’ directo ry).

Pour résoudre cet erreur supprimer le contenu du fichier /var/log/squid/access.log

nano /var/log/squid/access.log

Supprimer toutes les lignes

Générer a nouveau les statistiques

/usr/lib/cgi-bin/awstats.pl -config=NOMDEVOTRESERVEURSQUID –update

Create/Update database for config

« /etc/awstats/awstats.NOMDEVOTRESERVEURSQUID.conf » by AWStats version 6.95

(build 1.943)

From data in log file « /var/log/squid/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: 30

Found 0 dropped records,

Found 15 corrupted records,

Found 0 old records,

Found 15 new qualified records.

http://IP.DE.VOTRE.SERVEUR.AWSTATS/cgi-bin/awstats.pl?

config=NOMDEVOTRESERVEURSQUID

Les stats apparaissent.

Si vous n’avez pas les images qui s’affichent, créer un lien symbolique

ln -s /usr/share/awstats/icon/ /var/www/awstats-icon

2-2 Planifié la generation des stats

Pour généré les stats périodiquement, éditer la cron

crontab -e

Page 6: Installation Analyseur de Log Proxy Squid Avec Awstats _ Pomente Guillaume

02/08/13 INSTALLATION ANALYSEUR DE LOG PROXY SQUID AVEC AWSTATS | POMENTE Guillaume

www.guillaume-p.net/installation-analyseur-log-proxy-squid-awstats/ 6/6

Poster un commentaire

Ajouter la ligne suivante à la fin du fichier. Tous les jours à 7h du matin une mise à jour

sera effectuée

0 7 * * * perl /usr/lib/cgi-bin/awstats.pl -config=NOMDEVOTRESERVEURSQUID -update

Redémarrer la cron

/etc/init.d/cron restart

Auteur : POMENTE Guillaume

Mots-Clés

Pas de commentaires

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont

indiqués avec *

Nom *

Adresse de contact *

Site w eb

Commentaire

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b>

<blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Laisser un commentaire

© Copyright 2012 POMENTE Guillaume - Powered by WordPress