nginx本身就有提供一个监控的页面,需要编译的时候增加参数--with-http_stub_status_module,即可以配置打开这个监控页面。
在默认主机里面加上location或者者创立一个server进行监控。
server{
listen 8080;
server_name status.czlun.com;
location / {
stub_status on;
allow 127.0.0.1;
allow 192.168.1.0/24;
deny all;
access_log off;
}
}
2、重启nginx
/usr/local/nginx/sbin/nginx -s reload
3、直接访问页面即可以获取到数据
http://127.0.0.1:8088/status
Active connections: 1
server accepts handled requests
10029 10029 10114
Reading: 0 Writing: 1 Waiting: 0
active connections – 活跃的连接数量
server accepts handled requests — 总共解决了11989个连接 , 成功创立11989次握手, 总共解决了11991个请求
reading — 读取用户端的连接数.
writing — 响应数据到用户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经解决完正在等候下一次请求指令的驻留连接.