成都创新互联网站制作重庆分公司

zabbix监控nginx的配置-创新互联

这篇文章主要讲解了“zabbix监控nginx的配置”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“zabbix监控nginx的配置”吧!

创新互联公司专注于企业成都全网营销、网站重做改版、澄城网站定制设计、自适应品牌网站建设、H5场景定制商城网站制作、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为澄城等各大城市提供网站开发制作服务。

一、修改配置

修改nginx配置文件,在最后加上这条配置,其实php和nginx是配置在一起的,单独拿出来是为了脚本

server {             listen 127.0.0.1:80;             server_name 127.0.0.1;             location /nginx_status {                 stub_status on;                 access_log off;                 allow 127.0.0.1;                 deny all;             }     #        location ~ ^/(phpfpm_status)$ {     #            include fastcgi_params;     #            fastcgi_pass 127.0.0.1:9000;     #            fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;     #        } }

二、重启nginx

# service nginx restart

三、配置监控扩展

被监控主机端,zabbix_agentd.conf文件中添加上这个:

UserParameter=nginx[*],/etc/zabbix/scripts/nginx_status.py $1

四、将脚本放置在/etc/zabbix/scripts/目录下

chmod +x nginx_status.py

五、脚本

#!/usr/bin/env python #__*__coding:utf8__*__ import urllib2,sys,os def Nginx_status():     nginx_stats_dirt = {}     nginx_url = "http://127.0.0.1/nginx_status"     req = urllib2.Request(nginx_url)     response = urllib2.urlopen(req)     request_list = response.read().split("\n")     nginx_stats_dirt["active"] = request_list[0].split()[2]     nginx_stats_dirt["accepts"] = request_list[2].split()[0]     nginx_stats_dirt["handled"] = request_list[2].split()[1]     nginx_stats_dirt["requests"] = request_list[2].split()[2]     nginx_stats_dirt["reading"] = request_list[3].split()[1]     nginx_stats_dirt["writing"] = request_list[3].split()[3]     nginx_stats_dirt["waiting"] = request_list[3].split()[5]     if len(sys.argv) is not 2 or str(sys.argv[1]) not in nginx_stats_dirt.keys():         print "Usage: nginx_stauts.py $1 {active|accepts|handled|requests|reading|writing|waiting}"         exit(1)     else:         print nginx_stats_dirt[str(sys.argv[1])] if __name__ == '__main__':     try:         Nginx_status()     except urllib2.URLError,e:         print "%s,there may be something wrong with nginx!" %e

感谢各位的阅读,以上就是“zabbix监控nginx的配置”的内容了,经过本文的学习后,相信大家对zabbix监控nginx的配置这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:zabbix监控nginx的配置-创新互联
URL地址:http://cxhlcq.com/article/dodehd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部