On Thu, Oct 9, 2008 at 14:40, Andrej van der Zee
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was wondering what would be the right way to get the number of bytes
> / packets that are sent / received in an Apache module for httpd-2.1
> and higher (including the HTTP headers).

Check server/core.c and server/core_filters.c in the apache sources.
There are two filters there, ap_core_input_filter and
ap_core_output_filter. They are the first input/last output filters.
They are responsible of packaging the byte stream from the socket into
bucket brigades and of writing the contents of bucket brigades to the
socket. So, the output of ap_core_input_filter is really was comes
from the socket, and the input of ap_core_output_filter is really was
goes to the socket.

So you'll need to write your own filters that count the bytes and
insert them immediately after/before ap_core_input/output_filter.

This, if you want to count the headers. If not, for output it would be
easier to parse the access logs. For input, I don't know.

Wouldn't it be easier if you don't do this in apache but with some
sort of network monitoring tools? iptables, snmp, or something like
that? I'm not an expert, but I suppose some smart tools must be out
there, allowing you to filter by source IP, port, etc.

Sorin

Reply via email to