First Nginx To configure the Enable status
First, place the monitoring script on the client:
cat/etc/zabbix/monitor_scripts/nginx_status.sh //path name optional, specify this script when configuring Userparameter
#!/bin/bashhost=127.0.0.1port= " # 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} '} # run the requested Function$1
Second, configure the Zabbix client:
Configure zabbix_agentd.conf, make Unsafeuserparameters=1 //This does not seem necessary, I tried 0 or comments can
Then add a monitoring configuration in two ways:
1. Modify the zabbix_agentd.conf file
2. Open the Include file Include=
Add the following configuration
Userparameter=nginx.accepts,/bin/bash/etc/zabbix/monitor_scripts/nginx_status.sh acceptsUserParameter= Nginx.handled,/bin/bash/etc/zabbix/monitor_scripts/nginx_status.sh handleduserparameter=nginx.requests,/bin/ Bash/etc/zabbix/monitor_scripts/nginx_status.sh requestsuserparameter=nginx.connections.active,/bin/bash/etc/ Zabbix/monitor_scripts/nginx_status.sh activeuserparameter=nginx.connections.reading,/bin/bash/etc/zabbix/ Monitor_scripts/nginx_status.sh Readinguserparameter=nginx.connections.writing,/bin/bash/etc/zabbix/monitor_ Scripts/nginx_status.sh writinguserparameter=nginx.connections.waiting,/bin/bash/etc/zabbix/monitor_scripts/ Nginx_status.sh Waiting
Three: In the Zabbix Web Import configuration template (attachment, the Internet to find drops)
Note: Ensure that the zabbix_agentd.conf hostname configuration is correct, many articles on the internet did not mention this, at first I also did not notice, resulting in the configuration is not monitored, no data collected
Monitor nginx status with Zabbix