Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。现在作为一个开源项目,也越来越多的人使用它代替nginx。
1.添加Tengine配置tengine配置文件添加如下server
server { listen 80 ; server_name 127.0.0.1 ; location /nginx-status { stub_status on; allow 127.0.0.1; deny all; access_log off; } location /check-status { check_status; allow 127.0.0.1; deny all; access_log off; } }重载Tengine后,本机查看结果:
# curl 127.0.0.1/nginx-status
Active connections: 1
server accepts handled requests
1805146 1805146 1805167
Reading: 0 Writing: 1 Waiting: 0
以上为正常显示结果。
2.添加nginx监控源脚本cat /usr/local/zabbix/shell/nginx_status.sh
#!/bin/bashHOST="127.0.0.1"PORT="80" # Functions to return nginx stats function 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 3.编辑zabbix agentd配置文件修改如下:
vim /usr/local/zabbix/etc/zabbix_agentd.conf
添加zabbix自定义key,重启zabbix agentd
vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx_status_key
从zabbix server端获取监控数据,结果如下为正常: