Zabbix monitoring Nginx
Edit nginx.conf File
Add content inside the server location/nginx-status {stub_status on;access_log off;allow 127.0.0.1;//192.168.1.101 host Ipallow 192.168.1.101;deny all; }
Smooth restart Nginx
Nginx PID file storage location/usr/local/nginx/logs/nginx.pidkill-hup ' Cat/usr/local/nginx/logs/nginx.pid '
2.zabbix AGENTD Client Configuration
Edit/usr/local/zabbix/etc/zabbix_agentd.conf//Add the following unsafeuserparameters=1userparameter=nginx.accepts,/usr/at the end of the file Local/zabbix/scripts/nginx_status.sh accepts Userparameter=nginx.handled,/usr/local/zabbix/scripts/nginx_ Status.sh handled userparameter=nginx.requests,/usr/local/zabbix/scripts/nginx_status.sh requests UserParameter= nginx.connections.active,/usr/local/zabbix/scripts/nginx_status.sh Active userparameter= nginx.connections.reading,/usr/local/zabbix/scripts/nginx_status.sh Reading userparameter= nginx.connections.writing,/usr/local/zabbix/scripts/nginx_status.sh Writing userparameter= Nginx.connections.waiting,/usr/local/zabbix/scripts/nginx_status.sh Waiting
3. Edit the nginx_status.sh file
Cat /usr/local/zabbix/scripts/nginx_status.sh#!/bin/bashhost=127.0.0.1port= "TERM=$1# Functions" to return nginx statsfunction active { /usr/bin/curl "/http: $HOST $PORT/nginx-status" 2>/dev/null | grep " Active ' | awk ' {print $NF} '}function reading { /usr/bin/curl "http:/$HOST $PORT/nginx-status" 2>/dev/null | grep ' Reading ' | awk ' {print $2} '}function writing { /usr/bin/curl "http:/$HOST $PORT/nginx-status" 2>/dev/null | grep ' Writing ' | awk ' {print $4} '}function waiting { /usr/bin/curl "http:/$HOST $PORT/nginx-status" 2>/dev/null | grep ' Waiting ' | awk ' {print $6} '}function accepts { /usr/ bin/curl "/http $HOST: $PORT/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print $1} '}function handled { /usr/bin/ curl "/http $HOST: $PORT/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print $2} '}function requests { /usr/bin/ curl "/http $HOST: $PORT/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print $3} '} $TERM
4. Restart Zabbix_agentd
Service Zabbix_agentd Restart
5.zabbixweb Control-Side Import Template
6.zabbix Monitoring Client Add Nginx module
This article is from the "Ubuntu" blog, so be sure to keep this source http://thankinglove.blog.51cto.com/2311485/1793288
Zabbix monitoring Nginx