开启状态界面(状态页面配置)
开启status:
location /status {
stub_status {on | off};
allow 172.16.0.0/16;
deny all;
}
访问状态页面的方式:http://server_ip/status
状态码 | 表示的意义 |
---|---|
Active connections 2 当前所有处于打开状态的连接数 | |
accepts | 总共处理了多少个连接 |
handled | 成功创建多少握手 |
requests | 总共处理了多少个请求 |
Reading nginx | 读取到客户端的Header信息数,表示正处于接收请求状态的连接数 |
Writing nginx | 返回给客户端的Header信息数,表示请求已经接收完成,且正处于处理请求或发送响应的过程中的连接数 |
Waiting | 开启keep-alive的情况下,这个值等于active - (reading + writing),意思就是Nginx已处理完正在等候下一次请求指令的驻留连接 |
实例
[root@localhost conf]# vim nginx.conf
#access_log logs/host.access.log main;
location / {
root html;
index index.html;
}
location /status {
stub_status;
}
[root@localhost conf]# nginx
#看见以下界面代表成功了
通过过滤的方式进行监控status
[root@localhost conf]# curl http:/192.168.230.132/status
Active connections: 1
server accepts handled requests
3 3 3
Reading: 0 Writing: 1 Waiting: 0
[root@localhost conf]# curl -s http:/192.168.230.132/status |awk 'NR==4'
Reading: 0 Writing: 1 Waiting: 0
[root@localhost conf]# curl -s http:/192.168.230.132/status |awk 'NR==4{print $2}'
0
使用zabbix监控status
#先在从安装下zabbix
[root@localhost src]# cd /usr/local/
[root@localhost local]# tar xf zabbix-5.4.4.tar.gz
[root@localhost local]# cd zabbix-5.4.4
[root@localhost zabbix-5.4.4]# useradd -r -M -s /sbin/nologin zabbix
[root@localhost zabbix-5.4.4]# yum -y install vim wget gcc gcc-c++ make pcre-devel openssl openssl-devel
[root@localhost zabbix-5.4.4]# ./configure --enable-agent
LDAP support: no
IPv6 support: no
***********************************************************
* Now run