欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

zabbix监控nginx

程序员文章站 2022-07-11 10:38:27
...

实验环境

server1   172.25.41.11
server2   172.25.41.2

一·修改配置文件

[root@server2 ~]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm 
[root@server2 ~]# cd /etc/nginx/conf.d/
[root@server2 conf.d]# vim default.conf    #添加内容
[root@server2 conf.d]# nginx -t
[root@server2 conf.d]# nginx

zabbix监控nginx
网页访问:172.25.41.2/status
zabbix监控nginx

[root@server2 conf.d]# vim default.conf 
[root@server2 conf.d]# nginx -t
[root@server2 conf.d]# nginx -s reload

zabbix监控nginx

测试:只能是127.0.0.1
zabbix监控nginx
zabbix监控nginx

二·配置文件定义监控脚本key

[root@server2 conf.d]# cd /etc/zabbix/zabbix_agentd.d/
[root@server2 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server2 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf 
[root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf 
[root@server2 zabbix_agentd.d]# cat userparameter_nginx.conf 
UserParameter=nginx.active,curl -s http://127.0.0.1/status |grep Active | awk '{print $3}'
[root@server2 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart

zabbix监控nginx

三·在网页中创建nginx监控项

1.添加监控项

zabbix监控nginx
zabbix监控nginx

2.添加图形

zabbix监控nginx
zabbix监控nginx
zabbix监控nginx
zabbix监控nginx

四·再次添加脚本key

[root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf 
[root@server2 zabbix_agentd.d]# cat userparameter_nginx.conf 
UserParameter=nginx.active,curl -s http://127.0.0.1/status |grep Active | awk '{print $3}'
UserParameter=nginx.accepts,curl -s http://127.0.0.1/status |awk NR==3 | awk '{print $1}'
UserParameter=nginx.handled,curl -s http://127.0.0.1/status |wk NR==3 | awk '{print $1}'
UserParameter=nginx.requests,curl -s http://127.0.0.1/status |wk NR==3 | awk '{print $3}'
[root@server2 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart

zabbix监控nginx

五·再次打开网页

1.再次在网页中添加监控

zabbix监控nginx
zabbix监控nginx
zabbix监控nginx

2.添加图形

zabbix监控nginx

3.浏览

zabbix监控nginx

刷新多次后,发现图形会发生改变