Ich habe es dank dem How-To geschaft das ganze innerhalb von ein paar stunden ans laufen zu bekommen. Allerdings gabe es ein paar Fehler. Da bestimmt auch andere meine Probleme hatten oder haben werden poste ich drum hier meine scripts.
Um die logs im richtigen Format für AWSTATS zu erzeugen und um zu verhindern das Änderungen über schrieben werden erst die
pipelog.pl unter /usr/local/confixx ändern:
Code: Select all
#!/usr/bin/perl
###### Confixx-Apache-PipeLog
## zum Loggen der Webzugriffe pro User
########## erstellt am Fri Oct 12 12:42:52 2007 ###
$logDir = "/var/log/apache2/confixx/domains/access";
$stdLog = "/var/log/apache2/confixx/stdlog_access";
while(<STDIN>){
  ($domain, $log) = split(/:#:/, $_);
  $domain = lc($domain);
  if(-l "$logDir/$domain"){
    open(LOG, ">>$logDir/$domain") or next;
    $log =~ s/n|r//g;
    $log = "$log $domainn";
    print LOG $log;
    close(LOG);
   }else{
    open(LOG, ">>$stdLog") or next;
    print LOG "$domain :: $log";
    close(LOG);
  }
}
Jetzt alle Logs in den Userverzeichnissen löschen (web1 - webxx)
Meine 
index.html unter /srv/www/confixx/html/awstats
Code: Select all
<html>
<head>
<title>AWStats-Zugriffsstatistiken</title>
</head>
<body>
<center>
<h1>Geben Sie Ihren Benutzernamen oder Domain-Namen (domain.tld) ein:</h1>
<form action="http://vs163247.vserver.de/cgi-bin/awstats/awstats.pl"
method="GET" />
<input type="text" name="config" /><br />
<br />
<input type="submit" value="Einloggen" />
</form></body></html>
Meine 
.htaccess unter /srv/www/confixx/html/cgi-bin/awstats
Code: Select all
AuthName "awstats"
AuthType Basic
AuthUserFile /srv/www/confixx/html/cgi-bin/awstats/.htpasswd
require valid-user
Meine 
crontab für das die Statistic Updates in /etc
Code: Select all
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/36 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
*/1 * * * * root  /usr/local/confixx/confixx_counterscript.pl
*/30    *       *       *       *       root    /usr/local/awstats/awstats.sh >/dev/null 2>/dev/null
Und nun zu awstats unter /usr/local/awstats
Mein shellscript 
awstats.sh
Code: Select all
#!/bin/sh
perl /usr/local/awstats/awmakeconf.pl
/usr/local/awstats/awstats_updateall.pl now -awstatsprog=/srv/www/confixx/html/cgi-bin/awstats/awstats.pl
Da ich es meinen Benutzern ermöglicht habe Statistiken als 
domain.tld oder unter dem user 
web.. muste ich das perl script etwas auf boren und erweitern, ferner habe ich noch 2 kleine Fehler korrigiert.
Meine 
awmakeconf.pl
Code: Select all
#!/usr/bin/perl
#########################################################################
#                                                                       #
#               AWStats Configuration - Maker for Confixx               #
#               Copyright 2003 by Michael Mangold                       #
#               Contact: info@michael-mangold.net                       #
#                                                                       #
#               Modifizierungen (c) 2004 by Anton Dollmaier             #
#               Contact: info@aditsystems.de                            #
#                                                                       #
#########################################################################
$conf_path = '/etc/awstats';   # Pfad in dem die AWStats Konfigurationen liegen
$user_path = '/srv/www/';        # Pfad in dem Confixx die webs anlegt
$pwfile = "/srv/www/confixx/html/cgi-bin/awstats/.htpasswd"; # Passwort-Datei für die .htaccess-Abfrage
&loadConfFile;
use DBI;
$dbh = DBI->connect($db_address, $dbUser, $dbPw)
  or die( <ext('db_connect', '#2001', "$DBI::errstr") );
$cmd = 'rm '.$conf_path.'/awstats.*';
system($cmd);
$sql = "SELECT kunde, anbieter
        FROM kunden
        WHERE kunde != 'web0'
        ORDER BY kunde ASC";
my $sth = $dbh->prepare($sql);
$sth->execute;
while( @data = $sth->fetchrow_array )
     {
     $domains = '';
     $kunde = $data[0];
     $anbieter = $data[1];
     $logfile = $user_path.$kunde."/log/access_log";
     $sql = "SELECT domain FROM domains WHERE kunde = '".$kunde."' AND richtigedomain='1' ORDER BY domain ASC";
     my $res1 = $dbh->prepare($sql);
     $res1->execute;
     while ( @row = $res1->fetchrow_array )
           {
           my $subdomains = $row[0];
           my $Domainname = $subdomains;
           $subdomains =~ s/./\./g;
           $domains = "REGEX[^.*".$subdomains."$] ";
           $config = "LogFile="$logfile"nSiteDomain="$Domainname"nHostAliases="$domains"nAllowAccessFromWebToFollowingAuthenticatedUsers="$kunde Administrator $anbieter"nInclude "/etc/awstats/muster.conf"nn";
           system ("echo '$config' > $conf_path/awstats.$Domainname.conf");
           }
     $res1->finish();
     $sql = "SELECT domain FROM domains WHERE kunde = '".$kunde."' AND richtigedomain='1' ORDER BY domain ASC";
     my $res1 = $dbh->prepare($sql);
     $res1->execute;
     while ( @row = $res1->fetchrow_array )
           {
           my $subdomains = $row[0];
           $subdomains =~ s/./\./g;
           $domains .= "REGEX[^.*".$subdomains."$] ";
           }
     $res1->finish();
     $domain = $data[0];
     $config = "LogFile="$logfile"nSiteDomain="$domain"nHostAliases="$domains $kunde.vs163247.vserver.de"nAllowAccessFromWebToFollowingAuthenticatedUsers="$kunde Administrator $anbieter"nInclude "/etc/awstats/muster.conf"nn";
     system ("echo '$config' > $conf_path/awstats.$kunde.conf");
    }
$sth->finish();
system('cp /usr/local/awstats/muster.conf '.$conf_path);
#
# Generate Password-File for Statistics
#
# First, lets get Admin- and Reseller-Data
$sql = "SELECT anbieter,longpw FROM anbieter";
my $res = $dbh->prepare($sql);
$res->execute;
while ( @data = $res->fetchrow_array )
{
        $users .= $data[0].":".$data[1]."n";
}
$res->finish();
my $sql = "SELECT longpw FROM admin WHERE login='Administrator'";
my $sth = $dbh->prepare($sql);
$sth->execute;
while (@data = $sth->fetchrow_array)
      {
      $users .= "Administrator:".$data[0]."n";
      }
$sth->finish();
my $sql = "SELECT kunde, statistiklongpw
          FROM kunden
          WHERE statistik='1' AND kunde!='web0';";
my $sth = $dbh->prepare($sql);
$sth->execute;
while( @data = $sth->fetchrow_array )
    {
    $users .= $data[0].":".$data[1]."n";
    }
system('rm '.$pwfile);
system ("echo '".$users."' > ".$pwfile);
$sth->finish();
$dbh->disconnect;
sub loadConfFile{
my ($file, $base);
if(-T "/usr/local/confixx/confixx_main.conf"){
      $file = "/usr/local/confixx/confixx_main.conf";
       }
   else{
      $0 = $^X unless ($^X =~ m%(^|[/\])(perl)|(perl.exe)$%i);
      ($base) = $0 =~ m%^(.*)[/\]%;
      $base ||= ".";
      $file = "$base/confixx_main.conf";
      unless(-T $file){
         die("Couldn't find confixx_main.conf");
         }
      }
    do $file;
}
Das Script legt die Konfigdateien unter /etc/awstats für alle domains und alle webs in der Form awstats.
domain.tld.conf und  awstats.
web1.conf etc an.
Zuletzt noch meine 
muster.conf für awstats
Code: Select all
# AWSTATS CONFIGURE FILE 6.6
#-----------------------------------------------------------------------------
# Copy this file into awstats.www.mydomain.conf and edit this new config file
# to setup AWStats (See documentation in docs/ directory).
# The config file must be in /etc/awstats, /usr/local/etc/awstats or /etc (for
# Unix/Linux) or same directory than awstats.pl (Windows, Mac, Unix/Linux...)
# To include an environment variable in any parameter (AWStats will replace
# it with its value when reading it), follow the example:
# Parameter="__ENVNAME__"
# Note that environment variable AWSTATS_CURRENT_CONFIG is always defined with
# the config value in an AWStats running session and can be used like others.
#-----------------------------------------------------------------------------
# $Revision: 1.327 $ - $Author: eldy $ - $Date: 2006/04/21 22:28:49 $
LogType=W
LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %virtualname"
LogSeparator=" "
DNSLookup=1
DirData="/var/cache/awstats"
DirCgi="/cgi-bin/awstats"
DirIcons="/icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=3
AllowAccessFromWebToAuthenticatedUsersOnly=1
Ich hoffe das ich nichts vergessen habe und es euch weiter hilft.
Gruß
Oliver