Nginx,status,Zabbix,connections,usr
后端开发-php教程
Zabbix监控Nginx闲来麻将源码架设教程,无痛搞 ubuntu,重启tomcat在哪里重启,爬虫没朋友,php服务端框架,H2SeO4常温的状态lzw
在添加监控之前,必须要强调的是,Nginx必须支持stub_status状态的访问,不然一切都是空谈!!!网站上传源码软件,vscode运行终端很卡,ubuntu安装使用,tomcat jboss发布,sqlite存储文本文件,怎样判断爬虫是是不是很聪明,firebird php,杭州湾seo优化,动漫免费网站模板,织梦模板修改版权lzw
首先zabbix监控nginx 是根据nginx的Stub Status模块,抓取Status模块所提供的数据。如果想启用Stub Status模块,在编译nginx的时候要加上参数 --with-http_stub_status_module例如:./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module--with-http_ssl_module
在Nginx配置档中添加: location /nginx_status {stub_status on;access_log off;}
A、创建监控Nginx的key
传奇源码 vc,ubuntu电路仿真,tomcat访问到根目录,rstudio 淘宝爬虫,温江php培训学校,jsrender seolzw
nginx_status_keyvim /usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx_status_keyUserParameter=nginx.accepts,/usr/local/zabbix/shell/nginx_status.sh accepts UserParameter=nginx.handled,/usr/local/zabbix/shell/nginx_status.sh handled UserParameter=nginx.requests,/usr/local/zabbix/shell/nginx_status.sh requests UserParameter=nginx.connections.active,/usr/local/zabbix/shell/nginx_status.sh active UserParameter=nginx.connections.reading,/usr/local/zabbix/shell/nginx_status.sh reading UserParameter=nginx.connections.writing,/usr/local/zabbix/shell/nginx_status.sh writing UserParameter=nginx.connections.waiting,/usr/local/zabbix/shell/nginx_status.sh waiting
B、创建监控Nginx的脚本(记得加执行权限)
nginx_status.sh
vim /usr/local/zabbix/shell/nginx_status.sh#!/bin/bash # Script to fetch nginx statuses for tribily monitoring systems # License: GPLv4 # Set Variables BKUP_DATE=`/bin/date +%Y%m%d` LOG="/usr/local/zabbix/logs/nginx_status.log"HOST="192.168.0.217" #HOST非常重要,确保CURL能访问到这个IP地址的StatusPORT="80"# Functions to return nginx stats functionactive { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| grep 'Active' | awk '{print $NF}' } functionreading { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| grep 'Reading' | awk '{print $2}' } functionwriting { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| grep 'Writing' | awk '{print $4}' } functionwaiting { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| grep 'Waiting' | awk '{print $6}' } functionaccepts { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| awk NR==3 | awk '{print $1}' } functionhandled { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| awk NR==3 | awk '{print $2}' } functionrequests { /usr/bin/curl "http://$HOST:$PORT/nginx_status"2>/dev/null| awk NR==3 | awk '{print $3}' } # Run the requested function$1
C、在Zabbix Web界面中创建Templates App Nginx模版
(1)、先创建三个item,这个store value要求是每秒变化的
nginx.acceptsnginx.handlednginx.requests
我在这边做一个示例:模版中添加一个nginx.accepts的itemNamenginx.accepts TypeZabbix agentKey nginx.acceptsTypeof information Numeric (unsigned)Data Type DecimalUnits 空Store value Detal (speed per second)Show value As is
(2)、而后四个item Store value是不变的
nginx.connections.activenginx.connections.readingnginx.connections.writingnginx.connections.waiting
Namenginx.connections.activeTypeZabbix agentKey nginx.acceptsTypeof information Numeric (unsigned)Data Type DecimalUnits 空Store value As isShow value As is
创建完大概是这个样子,相信新手也能做出来!!!
D、现在点击要Tempates的Graphs,分别创建两个Graphs
监控Nginx(nginx.accepts、nginx.handled、nginx.requests)监控Nginx(nginx.connections.active、nginx.connections.reading、nginx.connections.writing、nginx.connections.waiting)
图像1:暂且取名为 Nginx_Interactive
图像2:暂且取名为 Nginx_Connection
E、Hosts-Templates-将刚才创建的Templates App Nginx链接到主机上面
完成之后大概是这个样子
F、在Screen中创建监控Nginx的Screen,将前面创建的两个图像添加进去
G、这时候在Zabbix Web页面中查看Nginx状态就OK~~~
mysql "too many connections" 错误 之 mysql解决方法 | mysql "too many connections" 错误 之 mysql解决方法 ...
MySQL出现too many connections(1040) | MySQL出现too many connections(1040) ...