1, 检查 NGINX 是否安装了状态模块
- [root@localhost nginx-1.6.3]# ./sbin/nginx -V #--with-http_stub_status_module
- nginx version: nginx/1.6.3
- built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
- TLS SNI support enabled
- configure arguments: --user=www --group=www --with-http_ssl_module --prefix=/app/nginx-1.6.3 --with-http_stub_status_module
2, 配置加载该模块
- [root@localhost nginx-1.6.3]# vi conf/vhost/default.conf
- server {
- listen 80;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- location /nginx_status { #nginx 状态监控 URL 访问地址
- stub_status on; #启动状态监控
- access_log off; #关闭状态模块的日志功能, 不影响正常日志
- allow 127.0.0.1; #只允许本机访问
- deny all; #拒绝所有
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
3, 获取 Nginx 监控状态值
- [root@localhost nginx-1.6.3]# curl http://127.0.0.1/nginx_status
- Active connections: 1
- server accepts handled requests
- 2 2 2
- Reading: 0 Writing: 1 Waiting: 0
来源: http://www.bubuko.com/infodetail-2687729.html