Welcome! Log In Create A New Profile

Advanced

counters in nginx

Roman Vasilyev
February 09, 2011 09:10PM
Hi,

I need to realize event counters in nginx.
So I've planned to create command like "counter".
And have something similar to HttpLimit(Zone/Req)Module,
so my config should looks like:
http {
counter_zone one $binary_remote_addr 10m;
...
server {
....
location / {
count one $my_event; #( $my_event can be 0 or 1 )
}
}
}
and have extra location like
location /my_one_stats { # will give stats to external script for
specific argument;
counter_handler one $args_one;
}

location /my_one_stats_reset { # will reset stats for specific argument;
counter_reset one $args_one;
}


In this case to be insured that my counter working in final phase I have
to register this handler in NGX_HTTP_LOG_PHASE phase, otherwise I
wouldn't know for sure that event is done.
But if I'll register it on init like:
h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers);
my handler will be called after HttpLogModule, so if I'll try to log
counter only previous value will be logged.

So my question:
1) May be exists more effective way to realize it, or it already realized?
2) What the best way to register handler before HttpLogModule but in
NGX_HTTP_LOG_PHASE?

Regards

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
SubjectAuthorPosted

counters in nginx

Roman VasilyevFebruary 09, 2011 09:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 105
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 165 on April 21, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready