Zabbix添加nginx监控项

##########Nginx配置##########

#查看是否安装nginx状态模块
nginx -V        
#--with-http_stub_status_module    

#修改配置文件  
vim /etc/nginx/nginx.cnf
...
location / {
   stub_status on;
...
nginx -t
nginx -s reload

#获取active活动连接数
curl -s http://localhost/nginx-status | awk 'NR==1{print $NF}'

##########Zabbix-agent配置##########
cat > /etc/zabbix/zabbix_agentd.d/nginx_active.conf <<aa
UserParameter=nginx.active, /usr/bin/curl -s http://localhost/nginx-status |awk 'NR==1{print \$NF}'
aa
systemctl restart zabbix-agent

#测试server端能否获取值
yum -y install zabbix-get
zabbix_get -s localhost -k nginx.active






posted @ 2018-07-11 15:53  Testder探索者  阅读(145)  评论(0编辑  收藏  举报