如何获取打开的连接数(尝试访问服务器的浏览器数量)。
我试着查看每个函数处理程序中可用的结构request_rec
。
request_rec->connection->conn_config
听起来像是最相关的字段(类型ap_conf_vector_t
但我不知道如何从中获取信息。
谢谢!
答案 0 :(得分:1)
没有专门的计数器。
你应该仔细检查所有apache的进程并根据它的状态计算它们,例如mod_status:
int server_limit, thread_limit;
int j, i, res;
int ready;
int busy;
worker_score *ws_record = apr_palloc(r->pool, sizeof *ws_record);
process_score *ps_record;
ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit);
ap_mpm_query(AP_MPMQ_HARD_LIMIT_DAEMONS, &server_limit);
ready = 0;
busy = 0;
for (i = 0; i < server_limit; ++i) {
ps_record = ap_get_scoreboard_process(i);
for (j = 0; j < thread_limit; ++j) {
ap_copy_scoreboard_worker(ws_record, i, j);
res = ws_record->status;
if (!ps_record->quiescing
&& ps_record->pid) {
if (res == SERVER_READY &&
ps_record->generation == ap_my_generation)
ready++;
else if (res != SERVER_DEAD &&
res != SERVER_STARTING &&
res != SERVER_IDLE_KILL)
busy++;
}
}
}