Nginx service status monitoring
In the Nginx plug-in module, stub_status can be used to monitor the status information of Nginx. This module may not be installed by default. You can simply add it during manual compilation.
1. Module Installation
Run the following command to check whether the module has been installed:
[Root @ bkjia nginx] #./nginx-V (V indicates the version number, module, and other information in uppercase, and v indicates only the version information in lowercase.
If installed, -- with-http_stub_status_module information is included in the displayed information. If you do not have this module, You need to reinstall it. The compilation command is as follows:
./Configure-with-http_stub_status_module
2. Nginx Configuration
After installation, you only need to modify the nginx configuration. The configuration is as follows:
Location/hxbcdnstatus {
Stub_status on;
Access_log off;
Allow 127.0.0.1;
Deny all;
# Auth_basic "NginxStatus ";
# Auth_basic_user_file conf/nginxstaus;
}
By default, only local access is allowed. If you can remotely view the IP address you need or simply remove Deny all. You can use the # htpasswd-c/usr/nginx/conf hxb command to create an encrypted file. Restart the Nginx service after the configuration is complete.
The Status Configuration can only be for a certain Nginx service. Currently, Nginx cannot monitor a single site.
3. view the status
After the configuration is complete, enter http: // 127.0.0.1/hxbcdnstatus in the browser to view the information, as shown below:
Active connections: 100
Server accepts handled requests
1075 1064 6253
Reading: 0 Writing: 5 Waiting: 95
4. parameter description
Active connections-number of active connections
Server accepts handled requests-107520387 connections are processed in total, and 107497834 handshakes are created successfully. A total of 639121056 requests are processed.
Each connection has three statuses: waiting, reading, and writing.
Reading-Number of headers read from the client. This operation only reads the Header information and enters the writing status immediately after reading, so the time is short.
Writing-Number of headers from the response data to the client. This operation not only reads the Header, but also waits for the Service to respond. Therefore, it takes a long time.
Waiting-after enabling keep-alive, wait for the resident connection of the next request command.
Under normal circumstances, the number of waiting is large, which does not indicate poor performance. If the number of reading + writing is large, the Service concurrency is faulty.
Supplement:
View the number of Nginx concurrent processes: ps-ef | grep nginx | wc-l
View the TCP connection status of the Web server: netstat-n | awk '/^ tcp/{++ S [$ NF]} END {for (a in S) print, S [a]}'
For more Nginx tutorials, see the following:
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
Nginx details: click here
Nginx: click here
This article permanently updates the link address: