httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: httpd-2.0/docs/manual/vhosts fd-limits.html.en
Date Sat, 15 Jun 2002 20:09:08 GMT
rbowen      2002/06/15 13:09:08

  Modified:    docs/manual/vhosts fd-limits.html.en
  Added configuration example, code example, and a little explanation, to
  facilitate logging all of your virtual hosts to a single file, and then
  splitting them back up after. Note that if Apache has problems with this
  many file handles, Perl might also. I'm not sure.
  Revision  Changes    Path
  1.5       +78 -7     httpd-2.0/docs/manual/vhosts/fd-limits.html.en
  Index: fd-limits.html.en
  RCS file: /home/cvs/httpd-2.0/docs/manual/vhosts/fd-limits.html.en,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- fd-limits.html.en	22 Sep 2001 19:39:26 -0000	1.4
  +++ fd-limits.html.en	15 Jun 2002 20:09:08 -0000	1.5
  @@ -17,7 +17,7 @@
       <p>When using a large number of Virtual Hosts, Apache may run
       out of available file descriptors (sometimes called <cite>file
  -    handles</cite> if each Virtual Host specifies different log
  +    handles</cite>) if each Virtual Host specifies different log
       files. The total number of file descriptors used by Apache is
       one for each distinct error log file, one for every other log
       file directive, plus 10-20 for internal use. Unix operating
  @@ -29,11 +29,11 @@
       this may not work if:</p>
  -      <li>Your system does not provide the setrlimit() system
  -      call.</li>
  +      <li>Your system does not provide the <code>setrlimit()</code>
  +      system call.</li>
  -      <li>The setrlimit(RLIMIT_NOFILE) call does not function on
  -      your system (such as Solaris 2.3)</li>
  +      <li>The <code>setrlimit(RLIMIT_NOFILE)</code> call does not 
  +      function on your system (such as Solaris 2.3)</li>
         <li>The number of file descriptors required exceeds the hard
  @@ -46,8 +46,11 @@
         <li>Reduce the number of log files; don't specify log files
  -      in the VirtualHost sections, but only log to the main log
  -      files.</li>
  +      in the <code><a 
  +      href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>

  +      sections, but only log to the main log files. (See <a
  +      href="#splitlogs">Splitting up your log files</a>, below, for more
  +      information on doing this.)</li>
           If you system falls into 1 or 2 (above), then increase the
  @@ -67,6 +70,74 @@
       document containing further details about file descriptor
       problems and how they can be solved on your operating
  +<h2><a name="splitlogs">Splitting up your log files</a></h2>
  +<p>If you want to log multiple virtual hosts to the same log file, you
  +may want to split up the log files afterwards in order to run
  +statistical analysis of the various virtual hosts. This can be
  +accomplished in the following manner.</p>
  +<p>First, you will need to add the virtual host information to the log
  +entries. This can be done using the <code><a
  +directive, and the <code>%v</code> variable. Add this to the beginning
  +of your log format string:</p>
  +<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><code>
  + LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost<br>
  + CustomLog logs/multiple_vhost_log vhost
  +<p>This will create a log file in the common log format, but with the
  +canonical virtual host (whatever appears in the
  +../mod/core.html#servername">ServerName</a> directive) prepended to
  +each line. (See <a 
  +href="../mod/mod_log_config.html#formats">Custom Log Formats</a> for
  +more about customizing your log files.)</p>
  +<p>When you wish to split your log file into its component parts (one
  +file per virtual host) you can use a program like the following to
  +accomplish this:</p>
  +<blockquote><table cellpadding="10"><tr><td bgcolor="#eeeeee"><pre>
  +# Filename: split_log
  +# Usage: split_log multiple_vhost_log
  +# Creates one log file per virtual host
  +use strict;
  +my $file = $ARGV[0]; # Name of the log file
  +my %fh; # File handles
  +# Read the log file, one line at a time
  +open LOG, $file;
  +foreach my $line (&lt;LOG&gt;) {
  +    $line =~ s/^(.*?) //;
  +    # Do we already have a file handle for this vhost?
  +    unless ($fh{$1})    {
  +        my $handle;
  +        open ($handle, '&gt;' , $1 . '_split');
  +        $fh{$1} = $handle;
  +    }
  +    # Write out the log entry
  +    select ($fh{$1});
  +    print $line;
  +close LOG;
  +# Close all the open file handles
  +foreach my $h ( keys %fh ) {
  +    close $h;
  +<p>This program, when run with the name of your vhost log file, will
  +generate one file for each virtual host that appears in your log file.
  +Each file will be called <code>hostname_split</code>.</p>
       <!--#include virtual="footer.html" -->

View raw message