Klaus Demo nginx / bac0cb3
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. Valentin Bartenev 9 years ago
4 changed file(s) with 24 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
969969
970970 if (c->reusable) {
971971 ngx_queue_remove(&c->queue);
972
973 #if (NGX_STAT_STUB)
974 (void) ngx_atomic_fetch_add(ngx_stat_waiting, -1);
975 #endif
972976 }
973977
974978 c->reusable = reusable;
978982
979983 ngx_queue_insert_head(
980984 (ngx_queue_t *) &ngx_cycle->reusable_connections_queue, &c->queue);
985
986 #if (NGX_STAT_STUB)
987 (void) ngx_atomic_fetch_add(ngx_stat_waiting, 1);
988 #endif
981989 }
982990 }
983991
7272 ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0;
7373 ngx_atomic_t ngx_stat_writing0;
7474 ngx_atomic_t *ngx_stat_writing = &ngx_stat_writing0;
75 ngx_atomic_t ngx_stat_waiting0;
76 ngx_atomic_t *ngx_stat_waiting = &ngx_stat_waiting0;
7577
7678 #endif
7779
510512 + cl /* ngx_stat_requests */
511513 + cl /* ngx_stat_active */
512514 + cl /* ngx_stat_reading */
513 + cl; /* ngx_stat_writing */
515 + cl /* ngx_stat_writing */
516 + cl; /* ngx_stat_waiting */
514517
515518 #endif
516519
557560 ngx_stat_active = (ngx_atomic_t *) (shared + 6 * cl);
558561 ngx_stat_reading = (ngx_atomic_t *) (shared + 7 * cl);
559562 ngx_stat_writing = (ngx_atomic_t *) (shared + 8 * cl);
563 ngx_stat_waiting = (ngx_atomic_t *) (shared + 9 * cl);
560564
561565 #endif
562566
510510 extern ngx_atomic_t *ngx_stat_active;
511511 extern ngx_atomic_t *ngx_stat_reading;
512512 extern ngx_atomic_t *ngx_stat_writing;
513 extern ngx_atomic_t *ngx_stat_waiting;
513514
514515 #endif
515516
7272 { ngx_string("connections_writing"), NULL, ngx_http_stub_status_variable,
7373 2, NGX_HTTP_VAR_NOCACHEABLE, 0 },
7474
75 { ngx_string("connections_waiting"), NULL, ngx_http_stub_status_variable,
76 3, NGX_HTTP_VAR_NOCACHEABLE, 0 },
77
7578 { ngx_null_string, NULL, NULL, 0, 0, 0 }
7679 };
7780
8285 ngx_int_t rc;
8386 ngx_buf_t *b;
8487 ngx_chain_t out;
85 ngx_atomic_int_t ap, hn, ac, rq, rd, wr;
88 ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa;
8689
8790 if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
8891 return NGX_HTTP_NOT_ALLOWED;
125128 rq = *ngx_stat_requests;
126129 rd = *ngx_stat_reading;
127130 wr = *ngx_stat_writing;
131 wa = *ngx_stat_waiting;
128132
129133 b->last = ngx_sprintf(b->last, "Active connections: %uA \n", ac);
130134
134138 b->last = ngx_sprintf(b->last, " %uA %uA %uA \n", ap, hn, rq);
135139
136140 b->last = ngx_sprintf(b->last, "Reading: %uA Writing: %uA Waiting: %uA \n",
137 rd, wr, ac - (rd + wr));
141 rd, wr, wa);
138142
139143 r->headers_out.status = NGX_HTTP_OK;
140144 r->headers_out.content_length_n = b->last - b->pos;
174178
175179 case 2:
176180 value = *ngx_stat_writing;
181 break;
182
183 case 3:
184 value = *ngx_stat_waiting;
177185 break;
178186
179187 /* suppress warning */