Nginx - 开启status用以监控状态信息
说明
介绍一下Nginx中开启Status来监控nginx的链接信息。
介绍
nginx状态信息功能简介:
Nginx 在编译安装 Nginx 的时候添加 --with-http_stub_status_module 参数,其功能是记录 Nginx 的基本访问状态信息,让使用者了解 Nginx 的工作状态,
可以用 /application/nginx/sbin/nginx -V 来查看是否添加了ngx_http_stub_status_module 模块。
启用NginxStatus
在自己的srever配置文件下添加一下代码:
location /ngx_status {
stub_status on;
access_log off;
#allow 127.0.0.1;允许哪个ip可以访问
}
示例代码:
server {
listen 80;
server_name zxliu.com;
error_log /home/zhangsan/data/log/nginx/zxliucom.log error;
root /home/zhangsan/data/www/a/;
location / {
index index.html;
}
location /NginxStatus{
stub_status on;
}
}
查看NginxStatus
在浏览器访问http://zxliu.com/NginxStatus
以下就是当前nginx的状态:
Active connections: 2
server accepts handled requests
744 744 1102
Reading: 0 Writing: 1 Waiting: 1
<h5>参数解析</h5>
active connections – 活跃的连接数量
server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
结尾
生命不公,而我不凡。