Idea for a statistics module

Hi!

We felt the stub status module was a bit too non-modular for our
internal services
and created a statistics module where each module can allocate their
stat counters
more dynamically.

It does have a hardcoded limit of around 64 counters currently, and
any suggestion
on how to make it dynamical is highly appreciated.

Apart from adding another “increment the counter”, it also requires
the event and core
modules to allocate the counters, why they have been given module init
functions.

You use it by adding

location /server-status {
statistics on;
}

and requesting

http://example.com/sever-status

for RFC822 formatted output or

http://example.com/sever-status?type=text/html

for more human friendly text.

The module adds the ability to use histograms of fixed bucket counts,
but note that
the counters will never be reset, so it is nowhere near a snapshot
value. For that we use
a monitoring/graphing system fed with the RFC822 output. This is also
the reason why the
default MIME type is text/plain, rather than text/html. The histograms
are quite useful for plotting
file sizes or request delays.

Hope you find it useful. The original code contained in the patch is
MIT licensed.
Documentation of the code… in the future.

It doesn’t seem to be tracking the request time properly, the counts
remain at 0 for all ranges.

Event-Accepted: 365
Event-Active: 160
Event-Handled: 365
Http-Requests-Reading: 0
Http-Requests-Writing: 1
Http-Requests-Total: 1754
Http-Time-Request:
-0=0
1-1=0
2-4=0
5-9=0
10-19=0
20-49=0
50-99=0
100-199=0
200-499=0
500-999=0
1000-1999=0
2000-4999=0
5000-9999=0
10000-19999=0
20000-=0
Http-Requests-Active: 1
Http-Requests-Writing-File: 0
Http-Upstreams-Total: 1700
Http-Upstreams-Active: 0
Http-Cached: 0

2009/10/8 Tommie G. [email protected]:

2009/10/9 zepolen [email protected]:

It doesn’t seem to be tracking the request time properly, the counts
remain at 0 for all ranges.

Oops. I never intended to include the request time counter in the patch.
Attached is an updated patch which adds the required _add_int() call.