rss
twitter
  • Showcase
  • Carrières
  • Support
  • GitLab
  • Espace client
  • Contact

Calcul des logs en lot avec AWStats

0

INDEX

Trucs utiles

  • Bench de AWStats
  • Doc sécurité

Pré-requis

  • Dans notre exemple, AWStats est installé dans /Homes/stats
  • L’éxécutable est /Homes/stats/wwwroot/cgi-bin/awstats.pl
  • Les stats sont accessibles depuis https://stats.italic.fr/cgi-bin/awstats.pl?config=domaine.com
  • Chaque domaine a son fichier de config dans /Homes/stats/wwwroot/cgi-bin/awstats.domaine.com.conf

Basique

  • Une commande qui devrait fonctionner du premier coup avant de commencer :

 

host2:cgi-bin user$ /Homes/stats/wwwroot/cgi-bin/awstats.pl -config=domaine.com
Create/Update database for config "/Homes/stats/wwwroot/cgi-bin/awstats.domaine.com.conf" by AWStats version 6.9 (build 1.925)
From data in log file "/Homes/stats/tools/logresolvemerge.pl /Homes/logs/domaine.com/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: 308054
 Found 0 dropped records,
 Found 2675 corrupted records,
 Found 305130 old records,
 Found 249 new qualified records.

Comment automatiser ?

Une boucle pour chercher tous les fichiers de conf :

host2:cgi-bin user$ for i in /Homes/stats/wwwroot/cgi-bin/*.conf; do echo `basename $i`; done
awstats.xxxxxxxx1.net.conf
awstats.xxxxxxxx2.fr.conf
awstats.xxxxxxxx3.fr.conf
awstats.xxxxxxxx4.com.conf
awstats.bajadaporelladoizquierdo.com.conf
(...)

Modification de awstats.pl pour formats de fichiers de config

Le but est d’autoriser 2 appels :

  • Soit en HTTP avec l’url config=domaine.com
  • Soit en SH avec passage de parametre config=awstats.domaine.com.conf
# Open config file
$FileConfig = $FileSuffix = '';
        foreach (@PossibleConfigDir) {
                my $searchdir = $_;
                if ( $searchdir && $searchdir !~ /[\\\/]$/ ) { $searchdir .= "/"; }

                if ( open( CONFIG, "$searchdir$SiteConfig" ) ) {
                        $FileConfig = "$searchdir$SiteConfig";
                        $FileSuffix = ".$SiteConfig";
                        last;
                }

                if ( open( CONFIG, "$searchdir$PROG.$SiteConfig.conf" ) ) {
                        $FileConfig = "$searchdir$PROG.$SiteConfig.conf";
                        $FileSuffix = ".$SiteConfig";
                        last;
                }

                if ( open( CONFIG, "$searchdir$PROG.conf" ) ) {
                        $FileConfig = "$searchdir$PROG.conf";
                        $FileSuffix = '';
                        last;
                }
        }
        if ( !$FileConfig ) {
                error(
"Couldn't open config file \"$PROG.$SiteConfig.conf\" nor \"$PROG.conf\" after searching in path \""
                          . join( ',', @PossibleConfigDir )
                          . "\": $!" );
        }

 

Dynamisation de la boucle

On fait en sorte que la boucle fasse les analyses une par une en acceptant le nom standard des fichiers de config de AWStats (donc awstats.*.conf), et qu’on n’ait pas besoin de saisir une liste des fichiers de conf nécessaire :

for i in /Homes/stats/wwwroot/cgi-bin/*.conf; do /Homes/stats/wwwroot/cgi-bin/awstats.pl -config=`basename $i` -update; done

Plannification en cron

Pour simplifier les choses sous OS X j’utilise Cronnix qui est pratique mais vous constatez comme moi que leur URL est vraiment à chier.
Dire que certains se plaignent avec « italic » !

DATE 29 Oct 2009
by : Germain
Author / Auteur

Social Share / Partager

    Leave a Reply / Répondre Annuler la réponse

    *
    *

    More in Sysadmin : Linux, Apache, GIT

    • Recevoir un mail lors de la connexion root à un serveur
    • Maildev : tester l'envoi de mails durant ses développements
    • Quel php.ini (MAMP ou Linux), quelle valeur de phpinfo() ?
    • Pense-bête Apache Server-Side Includes (SSI)
    • Ubuntu 14 chroot sftp et rsync

    Search the blog

    Blog categories

    • Front-end : HTML, CSS (13)
    • Workflow (1)
    • Front-end : javascript, jQuery (33)
    • Back-end : PHP, CMS (42)
    • Back-end : SQL, MySQL (20)
    • Sysadmin : Linux, Apache, GIT (75)
    • Designers : tools, advice (2)
    • Desktop : OS X (37)
    • Desktop : Microsoft (12)
    • Uncategorized (8)

    ITALIC™ Resources

    • Paramètres de connexion au serveur mail
    • Graphistes : séduire un développeur web
    • Dév front : nos bonnes pratiques
    • Mailing : nos (bonnes ?) pratiques
    • Environnement de travail Mac

    Recent posts

    • Autoriser le chargement de contenus mixtes non-https dans Chrome (Mac)
    • Afficher les logs MySQL
    • Recevoir un mail lors de la connexion root à un serveur
    • Changer l’interclassement de plusieurs tables MySQL à la fois (ou presque
    • Maildev : tester l’envoi de mails durant ses développements
    © 2008-2017 ITALIC™ • 8 bis rue Abel • 75012 PARIS • Tel +33 (0)1 48 44 46 35 • RCS PARIS 508 228 772 • Powered by WordPress & GoodLayers
    Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site web.
    Cookie settingsACCEPTER
    Manage consent

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Toujours activé
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    Enregistrer & appliquer