龙空技术网

Nginx启用状态监控

拾光文旅 87

前言:

而今小伙伴们对“nginx开启status”大致比较注重,你们都需要剖析一些“nginx开启status”的相关知识。那么小编也在网摘上搜集了一些有关“nginx开启status””的相关文章,希望看官们能喜欢,各位老铁们快快来了解一下吧!

检测是否启用了http状态模块

V大写会显示版本号和模块等信息、v小写仅显示版本信息。
nginx -Vnginx version: nginx/1.16.1built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

如果其中包括了--with-http_stub_status_module就说明已经包含了状态监控模块。

如果没有包括,通过如下命令安装:

./configure –with-http_stub_status_module
配置

nginx配置:

server { listen 80; server_name localhost;  location /ngx_status  { stub_status on; access_log off; #allow 127.0.0.1; #deny all; }}
重载Nginx

执行如下命令:

[root@localhost html]# nginx -s reload
查看状态
[root@localhost html]# curl localhost/ngx_statusActive connections: 2 server accepts handled requests 5 5 8 Reading: 0 Writing: 1 Waiting: 1
参数解释

active connections – 活跃的连接数量
server accepts handled requests — 总共处理了5个连接 , 成功创建5次握手, 总共处理了8个请求
reading — 读取客户端的连接数.
writing — 响应数据到客户端的数量
waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接

标签: #nginx开启status #nginxaccepts