httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Edouard BABIN <lis...@jeb.com.fr>
Subject Re: Web Stats when using Dynamically configured virtual hosts.
Date Tue, 23 Apr 2002 10:42:49 GMT
Hi,

You can try this in apache.conf:
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
vcombined
CustomLog "| /usr/local/apache/bin/write_log.pl" vcombined

The script is

#!/usr/local/bin/perl

while ($log_line = <STDIN>) {

    ($vhost) = split (/\s/, $log_line);
# vhost is now the first word of the log line (the host)
    $vhost = lc ($vhost);  # we want the host in lowercase

        if ($vhost =~ /\./) {
            $vhost =~ /([0-9,a-z,A-Z,-]*)\.([0-9,a-z,A-Z,-]*)$/;
            $vhost = "$1.$2";
        }
        else { qx "echo \"Host $vhost as been found in log\" >>
/usr/local/apache/logs/logging/err";

# if host contains "." he look like to be ok
# we set $vhost to domaine.tld, there is an error here, if the domaine is
# domaine.co.uk for exemple he will be logged as co.uk, you may need to fix
#this, else the vhost is stange we log it in an error file

    $log_line =~ s/\"/\\"/g;
    $log_line =~ /\s+(.*)/;
# $1 now contains the normal logline without vhost

if ($vhost ne "worm.com") {
if ($vhost ne "intel.com"){
if ($vhost ne "186.251")  {
if ($vhost ne "www") {
if ($vhost ne "s3.com") {
qx "echo \"$1\" >> /usr/local/apache/logs/hosts/$vhost";
} } } } }
# And finaly we write the log file, I get request for the listed domaine,
# It's virus request I think...

}
exit 0;

ps: you can also user open() and close(), it would be better if you have lot
of request


On 23/04/02 9:34, DownUnder Dan (danes@image.dk) wrote:

> HI all!
> 
> I use dynamically configured virtual hosts. I have about 30 web sites running
> off my little Suse 7.1 Linux server.
> What I would like to do is install some kind of webstats program so that I can
> see the access stats for each of these domains.  My problem is that I don't
> know if such programs are geared to understand the access log file of
> dynamically configured virtual hosts.
> 
> Can you suggest a good web stats program that analyses the access log? Any
> suggestions? I am a newbie at all of this.
> 
> =======================================
> Here are a copy of snips from my httpd.conf:
> =======================================
> 
> # The location and format of the access logfile (Common Logfile Format).
> # If you do not define any access logfiles within a <VirtualHost>
> # container, they will be logged here.  Contrariwise, if you *do*
> # define per-<VirtualHost> access logfiles, transactions will be
> # logged therein and *not* in this file.
> #
> CustomLog /var/log/httpd/access_log common
> 
> [snip]
> 
> 
> # get the server name from the Host: header
> UseCanonicalName Off
> 
> # this log format can be split per-virtual-host based on the first field
> LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
> CustomLog /var/log/httpd/access_log vcommon
> 
> # include the server name in the filenames used to satisfy requests
> 
> VirtualDocumentRoot /usr/local/httpd/htdocs/%0/htdocs
> VirtualScriptAlias  /usr/local/httpd/htdocs/%0/cgi-bin


-- 
   Jean-Edouard BABIN
Mail : Jeb@jeb.com.fr
Web  : www.Jeb.com.fr
Icq  : 27305084
Irc  : Jeb @#Mac-fr , @#So .. UnderNet.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message