counters

theromis1 nginx-forum at nginx.us
Thu Feb 28 21:23:43 UTC 2013


пример я обновил

========================================================
http {
    # allocating 10Mb for counetr with name "host_counter"
    # and hashing function by $client_ip
    counter_zone  host_counter  $client_ip  10m;

    # same for "hit_counter"
    counter_zone  hit_counter   $client_ip  10m;
 
    ...
 
    server {
 
        ...
 
        location ^~ /some/stats/ {
            counter   host_counter  1; #increase host_counter by one
        }

        location ^~ /some/stats/hit/ {
            counter   hit_counter  3; #increase hit_counter by some other
value
        }

        location ^~ /some/other/stats/ {
            counter   host_counter  $inc_var; #increase counter by some
variable atoi
        }

        location ~* /stats/get_counter/(?P<id>.*)$ {
            counter_get host_counter $counter $id;
            return 200 $counter;
        }

        location ~* /stats/counter_get/(?P<id>.*)$ {
            counter_get host_counter $counter $id;
            return 200 $counter;
        }

        location ~* /stats/counter_drop/(?P<id>.*)$ {
            counter_drop host_counter $id;
        }

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,236733,236741#msg-236741



Подробная информация о списке рассылки nginx-ru