Set Nginx Status page, if not, you may need to compile the installation, use Nginx-v to view the compilation parameters
server {
Listen 81;
server_name localhost;
Location/nginx_status
{
Stub_status on;
Access_log off;
}
Location/php-fpm_status
{
#fastcgi_pass 127.0.0.1:9000;
Fastcgi_pass Unix:/dev/shm/php-cgi.sock;
Fastcgi_param script_filename $fastcgi _script_name;
Include Fastcgi_params;
}
}
Nginx Script:
#!/bin/bash
# -------------------------------------------------------------------------------
# Notice
# Apply Zabbix version 2.4.x to 3.0.3
# Nginx Need to open Nginx status modules
#################################################################################
Port= "81"
clu= "/usr/bin/curl http://127.0.0.1: $PORT/nginx_status"
#FILE =/tmp/nginx_status.txt
if [[$# = 1]]; Then
Case is in
#当前处于打开状态的连接数
Active)
output= ' $CLU 2>/dev/null |awk '/active/{print $} ' 2>/dev/null
Echo $output
;;
#共处理的链接, already accepted links
Server
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#成功创建握手, links that have been processed
Accepts)
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#已经处理的链接, a total of requests for processing
Handled
output= ' $CLU 2>/dev/null |awk ' nr==3{print $} ' 2>/dev/null
Echo $output
;;
#读取客户端的连接数, the number of connections that are in the receiving request state
Reading
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
#相应数据到客户端的数量, the number of connections in the process of processing a request or sending a response that the request has accepted to complete
Writing)
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
#开启keep-alive, this value is equal to active-(reading+writing), meaning that Nginx has finished processing the resident link waiting for the next request instruction
#保持链接模式, and the number of active connections
Waiting)
output= ' $CLU 2>/dev/null |awk ' nr==4{print $} ' 2>/dev/null
Echo $output
;;
*)
echo "Usage:$0{active|server|accepts|handled|reading| Writing| Waiting} "
;;
Esac
Fi
#nginx
Userparameter=nginx.status[*],/usr/local/zabbix/scripts/nginx_status.sh $ $