------------------------------------------------
On Mon, 03 Feb 2003 13:09:47 -0500, Jeremy Schwartz <[EMAIL PROTECTED]> wrote:

> Not trying to reinvent the wheel.
> 
> I am using Analog for the analysis.
> 
> I am trying to split the server combined log into individual vhost logs. I
> can then run each through Analog to produce individual reports.

> > Don't reinvent the wheel.  There are a number of fine log analysis
> > utilities, such as analog.
> > 
> > xoa

Out of curiousity is there a reason why you are not handling this at the Apache level? 
 Each vhost can have its own set of logs at the start that then would not need to be 
pulled apart.  Is this a possible scenario for you going forward? (granted it doesn't 
help now).  It would seem that your task would be better handled with shell script 
possibly since you already have the command line for creating the file(s) from the 
main log, so then just wrap that command in a foreach that takes your directory names 
as input. 

Something along the lines of:

#!/bin/sh

for dir in `ls -1 /webroot/`; do
  cat /var/log/httpd/access_log | grep "$dir" >
/var/log/httpd/access_log_$dir
done

I am no shell hacker and the above is untested, but you get the idea.  In general Perl 
would not be a good choice for performing something so simple that already has a 
command line solution available. 

If you were going to do it in Perl, rather than looking for each vhost in the log 
file, you would be better off unpacking or splitting, etc. the log line and storing 
that line to an array that is associated with the particular vhost in the log line and 
then printing each vhost's array to a file, or you would have to open a filehandle for 
each vhost at the beginning of the script and then just print the line to whichever 
filehandle is associated with a particular vhost.  Stepping through every line of the 
log file foreach of the vhosts in Perl would probably be a really bad way to handle 
things.

I would still suggest letting Apache do the splitting by not storing one main log with 
all vhost content, it is much easier to put the logs back together to get a complete 
picture than it is to disect them after the fact.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to