码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix监控nginx

时间:2016-11-15 01:54:04      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:服务   主机   cep   mon   赋权   agent   ttl   requests   分享   

前提条件:nginx需要加载--with-http_stub_status_module

/usr/local/webserver/nginx/sbin/nginx -V

nginx version: nginx/1.9.9

built by gcc 4.4.7 20120313 (Red Hat4.4.7-4) (GCC)

configure arguments:--prefix=/usr/local/webserver/nginx --with-http_stub_status_module--with-http_ssl_module --with-pcre=/opt/pcre-8.35

如果发现没有--with-http_stub_status_module 的监控模块就需要手动开启

./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module--with-http_ssl_module --with-pcre=/opt/pcre-8.35

make


一、编辑nginx配置文件

server
{
        listen 80;
        #index index.html;
        server_name 192.168.1.34 127.0.0.1;
        #root /data/www/static;

        location /nginx_status {
            stub_status on;
            access_log off;
            allow 127.0.0.1;
            allow 192.168.0.0/16;
            allow 10.195.1.100;
            deny all;
        }
}


测试:

curl http://127.0.0.1/nginx_status
Active connections: 1
server accepts handled requests
 10054822 10054822 1313691
Reading: 0 Writing: 1 Waiting: 0



二、配置agent文件

修改

ll /usr/local/zabbix/etc/zabbix_agentd.conf

grep -v "#" zabbix_agentd.conf

Server=192.168.1.100
ServerActive=192.168.1.100
Hostname=192.168.1.34

#自定义脚本

UserParameter=nginx.status[*],/usr/local/zabbix/scripts/nginx_status.sh $1

加载脚本文件(见附件nginx_status.sh


赋权限 chmod 755 nginx_status.sh(可能会导致图像无法显示)

测试:如果有输出说明脚本没问题了

./nginx_status.sh  handled
10055263


重启agent服务

/usr/local/zabbix/sbin/zabbix_agentd



三,上传监控模板到zabbix web管理界面,导入模板

技术分享


并添加到主机

技术分享




四,页面打印信息

技术分享



ps:脚本和模板见附件

参考博客:http://www.ttlsa.com/zabbix/zabbix-monitor-nginx-performance/








本文出自 “7835882” 博客,请务必保留此出处http://crfsz.blog.51cto.com/7835882/1872715

zabbix监控nginx

标签:服务   主机   cep   mon   赋权   agent   ttl   requests   分享   

原文地址:http://crfsz.blog.51cto.com/7835882/1872715

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!