Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_stub_status_module.c @ 5115:a29c574d61fa
Status: introduced the "ngx_stat_waiting" counter.
And corresponding variable $connections_waiting was added.
Previously, waiting connections were counted as the difference between
active connections and the sum of reading and writing connections.
That made it impossible to count more than one request in one connection
as reading or writing (as is the case for SPDY).
Also, we no longer count connections in handshake state as waiting.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 15 Mar 2013 20:00:49 +0000 |
parents | 1c472e3b8c10 |
children | ee739104d164 |
comparison
equal
deleted
inserted
replaced
5114:a46c1cfe7263 | 5115:a29c574d61fa |
---|---|
71 1, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | 71 1, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
72 | 72 |
73 { ngx_string("connections_writing"), NULL, ngx_http_stub_status_variable, | 73 { ngx_string("connections_writing"), NULL, ngx_http_stub_status_variable, |
74 2, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | 74 2, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
75 | 75 |
76 { ngx_string("connections_waiting"), NULL, ngx_http_stub_status_variable, | |
77 3, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | |
78 | |
76 { ngx_null_string, NULL, NULL, 0, 0, 0 } | 79 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
77 }; | 80 }; |
78 | 81 |
79 | 82 |
80 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) | 83 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) |
81 { | 84 { |
82 size_t size; | 85 size_t size; |
83 ngx_int_t rc; | 86 ngx_int_t rc; |
84 ngx_buf_t *b; | 87 ngx_buf_t *b; |
85 ngx_chain_t out; | 88 ngx_chain_t out; |
86 ngx_atomic_int_t ap, hn, ac, rq, rd, wr; | 89 ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa; |
87 | 90 |
88 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { | 91 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { |
89 return NGX_HTTP_NOT_ALLOWED; | 92 return NGX_HTTP_NOT_ALLOWED; |
90 } | 93 } |
91 | 94 |
124 hn = *ngx_stat_handled; | 127 hn = *ngx_stat_handled; |
125 ac = *ngx_stat_active; | 128 ac = *ngx_stat_active; |
126 rq = *ngx_stat_requests; | 129 rq = *ngx_stat_requests; |
127 rd = *ngx_stat_reading; | 130 rd = *ngx_stat_reading; |
128 wr = *ngx_stat_writing; | 131 wr = *ngx_stat_writing; |
132 wa = *ngx_stat_waiting; | |
129 | 133 |
130 b->last = ngx_sprintf(b->last, "Active connections: %uA \n", ac); | 134 b->last = ngx_sprintf(b->last, "Active connections: %uA \n", ac); |
131 | 135 |
132 b->last = ngx_cpymem(b->last, "server accepts handled requests\n", | 136 b->last = ngx_cpymem(b->last, "server accepts handled requests\n", |
133 sizeof("server accepts handled requests\n") - 1); | 137 sizeof("server accepts handled requests\n") - 1); |
134 | 138 |
135 b->last = ngx_sprintf(b->last, " %uA %uA %uA \n", ap, hn, rq); | 139 b->last = ngx_sprintf(b->last, " %uA %uA %uA \n", ap, hn, rq); |
136 | 140 |
137 b->last = ngx_sprintf(b->last, "Reading: %uA Writing: %uA Waiting: %uA \n", | 141 b->last = ngx_sprintf(b->last, "Reading: %uA Writing: %uA Waiting: %uA \n", |
138 rd, wr, ac - (rd + wr)); | 142 rd, wr, wa); |
139 | 143 |
140 r->headers_out.status = NGX_HTTP_OK; | 144 r->headers_out.status = NGX_HTTP_OK; |
141 r->headers_out.content_length_n = b->last - b->pos; | 145 r->headers_out.content_length_n = b->last - b->pos; |
142 | 146 |
143 b->last_buf = (r == r->main) ? 1 : 0; | 147 b->last_buf = (r == r->main) ? 1 : 0; |
173 value = *ngx_stat_reading; | 177 value = *ngx_stat_reading; |
174 break; | 178 break; |
175 | 179 |
176 case 2: | 180 case 2: |
177 value = *ngx_stat_writing; | 181 value = *ngx_stat_writing; |
182 break; | |
183 | |
184 case 3: | |
185 value = *ngx_stat_waiting; | |
178 break; | 186 break; |
179 | 187 |
180 /* suppress warning */ | 188 /* suppress warning */ |
181 default: | 189 default: |
182 value = 0; | 190 value = 0; |