Environment:
Zabbix 2.0
Zabbix server:172.28.2.119
Zabbix Nginx Client: 172.28.2.151
The premise is that nignx when compiling the installation:--with-http_stub_status_module-----This everybody knows!!
Also, add the following in the Nginx configuration file:
Location/status
{
stub_status on;
Access_lod off;
Allow 127.0.0.1;
Allow 172.28.2.119; #这是我们zabbix监控服务器IP
}
The following Zabbix on the Nginx monitoring principle:
Zabbix Server <---(Zabbix Agent)---> Nginx client key (to be written to the client configuration file) <---script--->nginx state parameters
The Nginx Web interface nginx status is shown in the following figure:
1. Create a status parameter to get Nginx data transfer to server-side script
[Root@zabbix_server script]# cat >>/usr/local/sbin/nginx_status.sh << EOF #!/bin/bash # script to FE tch Nginx statuses for tribily monitoring systems # license:gplv4 # Set Variables bkup_date= '/bin/date +%y%m% d ' log= "/etc/zabbix/nginx_status.log" #HOST = '/sbin/ifconfig eth0 |
Sed-n '/inet/{s/.*addr://;s/. *//;p} ' host= '/sbin/ifconfig eth0 "|grep inet addr" |awk-f[: ""] ' {print $} ' Port= # functions to return Nginx stats function active {/usr/bin/curl ' http://$HOST: $PORT/statu S "2>/dev/null| grep ' Active ' | awk ' {print $NF} '} function reading {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/nul l| grep ' Reading ' | awk ' {print $} '} function writing {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | grep ' Writing ' | awk ' {print $} '} function waiting {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | grep ' Waiting ' | awk ' {print $} '} function accepts {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | awk nr==3 | awk ' {print} '} ' function handled {/usr/bin/curl ' http://$HOST: $PORT/status ' 2>/dev/null| awk N r==3 | awk ' {print $} '} function requests {/usr/bin/curl ' http://$HOST: $PORT/status ' 2>/dev/null| awk nr==3 | awk ' {print $} '} # Run the requested function ' EOF '
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/