- A+
所属分类:Nginx
nginx和php-fpm一样内建了一个状态页,对于想了解nginx的状态以及监控nginx非常有帮助。为了后续的zabbix监控,我们需要先了解nginx状态页是怎么回事。
1. 启用nginx status配置
在默认主机里面加上location或者你希望能访问到的主机里面。
1 2 3 4 5 6 7 8 9 10 11 |
server { listen *:80 default_server; server_name _; location /ngx_status { stub_status on; access_log off; #allow 127.0.0.1; #deny all; } } |
2. 重启nginx
请依照你的环境重启你的nginx
1 |
# service nginx restart |
3. 打开status页面
1 2 3 4 5 |
# curl http://127.0.0.1/ngx_status Active connections: 11921 server accepts handled requests 11989 11989 11991 Reading: 0 Writing: 7 Waiting: 42 |
4. nginx status详解
active connections – 活跃的连接数量
server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
5. 完成
下篇文章我们将使用zabbix监控nginx

微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
19/05/2017 下午 6:29 沙发
楼主,Active connections和Reading: 0 Writing: 1 Waiting: 3都可以获取到正常到值,但是zabbix里server accepts handled requests获取到三个值都是0.
13/08/2018 上午 10:47 1层
@匿名 我也遇到这个问题,请问如何解决?agent_get 可以正常获取数据。
17/05/2016 下午 4:21 板凳
我已经配置好了,不过发现个问题:
1. 我的环境是测试环境目前没有外界访问,但是发现server accepts handled requests 这个指标一直在涨,这是正常的么
2. 如下是我curl的输出:Active Connection 1是指哪个连接呢?是脚本产生的么?
curl http://127.0.0.1:8081/nginx_status
Active connections: 1
server accepts handled requests
4067 4067 3509
Reading: 0 Writing: 1 Waiting: 0
02/06/2016 下午 2:31 1层
@Jilong 有同样的困惑,找到这里来了,希望有人能给个答复。 :neutral:
17/12/2015 上午 11:27 地板
rewrite ^(.*) https://$server_name$1 permanent; 我的url重新就写了这么一条信息
17/12/2015 上午 11:37 1层
@longdechuanren517 如果写在server里location之外,肯定不行的
17/12/2015 下午 1:41 2层
@运维生存时间 嗯嗯,我后来重新再写过虚拟主机,然后脚本监控的时间监控别的端口就行。我之前还以为只能够监控80端口呢。多谢
17/12/2015 上午 11:03 4楼
我想问下我的nginx开启了ssl证书认证,然后按照文档去做的时候没有显示状态,显示的是页面代码。这是为什么。有没有可能和我的url做转发有关系
17/12/2015 上午 11:20 1层
@longdechuanren517 url多了/
10/10/2015 上午 10:14 5楼
请问斑竹,nginx的每个虚拟主机能够独立开启状态监控,并显示各自网址的连接状态吗?
我的多个网址开启了监控以后,连接状态是一样的,这样就没有意义了。
11/10/2015 下午 5:02 1层
@木头人SeanZhang 暂时没有这方面的插件
19/08/2015 上午 11:33 6楼
nginx stub_status 请问可以按每个虚拟主机来分配吗? 独立开显示,之前看到用$host区分,但没成功…
10/03/2015 下午 6:01 7楼
mark
–with-http_stub_status_module
24/06/2015 上午 10:55 1层
@牧童Damian nice, you help me..
来自外部的引用: 2