如何获取nginx使用的当前工作者连接?

Har*_*hta 6 ubuntu nginx

Nginx.conf,看起来像这样

user www-data; worker_processes 4; pid /run/nginx.pid;

events { worker_connections 768; # multi_accept on; }

该命令ulimit -n给出了可用的工作者连接数,我想要nginx当前使用的数字.

Tan*_*Tat 6

ngx_http_stub_status_module模块提供对基本状态信息的访问.

location /basic_status {
    stub_status;
}
Run Code Online (Sandbox Code Playgroud)

此配置创建一个简单的网页,其基本状态数据可能如下所示:

Active connections: 291 
server accepts handled requests
 16630948 16630948 31070465 
Reading: 6 Writing: 179 Waiting: 106 
Run Code Online (Sandbox Code Playgroud)

资料来源:https://nginx.org/en/docs/http/ngx_http_stub_status_module.html

  • 这并不能回答问题。有没有办法准确找到当前正在使用的工作人员(或工作人员连接)的数量? (4认同)
  • 有没有办法从终端获取这些信息,而不是让 nginx 服务一个页面? (2认同)