Nginx and PHP-FPM have built a status page that is very helpful to understand the status of Nginx and to monitor Nginx. For subsequent Zabbix monitoring, we need to first understand how the Nginx status page is going.
1. Enable Nginx status configuration
add location to the default host or the host you wish to access.
server {
listen *:80 default_server;
server_name _;
Location/ngx_status
{
stub_status on;
Access_log off;
#allow 127.0.0.1;
#deny all;
}
}
2. Restart Nginx
Please restart your nginx in accordance with your circumstances.
3. Open Status Page
# 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 Detailed
- Active connections– number of actively connected connections
- The server accepts handled requests-has handled 11,989 connections, successfully created 11,989 handshakes, and handled 11,991 requests in a total
- Reading-reads the number of connections to the client.
- Number of writing-response data to client
- waiting-Open keep-alive, this value equals active– (reading+writing), meaning that Nginx has finished processing the resident connection waiting for the next request instruction.
Script, the following directives specify the ability to enable getting nginx working status.
Location/nginxstatus {
stub_status on;
Access_log Logs/nginxstatus.log;
Auth_basic "Nginxstatus";
}
Active connections:2
Server accepts handled requests
129 reading:1 writing:1
waiting:0
- Active connections: The number of active connections initiated on the backend.
- The Server accepts handled Requests:nginx handled 24 connections, successfully creating 24 handshakes (proving that there were no failures), processing 129 requests in total.
- Reading:nginx the number of header information read to the client.
- Writing:nginx the number of header information returned to the client.
- Waiting: When Keep-alive is turned on, this value equals active– (reading + writing), meaning that the nginx has been processed and is waiting for the next request to host the connection.
Therefore, in the case of high efficiency, the request is quickly processed, the number of waiting is normal. If the number of reading +writing is higher, the amount of concurrent traffic is indicated.