zabbix监控nginx

1、环境:

server1:172.25.17.101zabbix-server
server2:172.25.17.102agent客户端

 

 

 

server1配置:https://blog.csdn.net/SS_CC_Go/article/details/98191211

2、部署

server2上:nginx部署

tar zxf nginx-1.14.0.tar.gz 
cd nginx-1.14.0
cd src/core/
vim nginx.h
    14 #define NGINX_VER          "nginx/"    //修改server名称
cd nginx-1.14.0/
cd auto/cc
    vim gcc 
        171 # debug
        172 #CFLAGS="$CFLAGS -g"
./configure --prefix=/usr/local/nginx --with-http_ssl_module  --with-http_stub_status_module --with-threads --with-file-aio	//生成Makefile文件,检测编译环境是否完善
yum install gcc  pcre-devel  openssl-devel -y	//解决依赖性
./configure --prefix=/usr/local/nginx --with-http_ssl_module  --with-                 http_stub_status_module --with-threads --with-file-aio
make
make install
cd /usr/local/nginx/
cd sbin/
ln -s /usr/local/nginx/sbin/nginx /sbin/
nginx 	//开启
vim /usr/local/nginx/conf/nginx.conf
 47         location /status {
 48                 stub_status on;     开启状态检测功能
 49                 access_log off;
 50                 allow 127.0.0.1;    更安全
 51                 deny all;
 52         }}

nginx -t 	//检测语法错误
nginx -s reload 	//重新加载
nginx -s stop	//停止
nginx 
cd -
cd html/
vim test.html
    <h1>www.westos.org</h1>

测试:

curl http://127.0.0.1/status                     查看http的请求状态

cd /etc/zabbix/zabbix_agentd.d
    cp userparameter_mysql.conf userparameter_nginx.conf
    vim userparameter_nginx.conf
        UserParameter=nginx.active,curl -s http://localhost/status | grep Active | awk '{print $3}'    存活的连接数
        UserParameter=nginx.accept,curl -s http://localhost/status | awk NR==3 | awk '{print $1}'    接收的请求
        UserParameter=nginx.request,curl -s http://localhost/status | awk NR==3 | awk '{print $3}'    处理的请求

systemctl restart zabbix-agent

3、server1上

debug

浏览器:http://172.25.17.101/zabbix

添加nginx监控

需要添加三次,关键字是nginx.active,nginx.accept,nginx.request
1、配置--主机--选中server2--监控项(添加)
    注意:监控项的键值必须和server2上/etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf中的关键字保持一致,名称随便。
2、创建图形,将监控项导入
3、预览监控图形
    

web界面字体调整

[root@server1 ~]# cd /usr/share/zabbix/fonts/
[root@server1 fonts]# ll
lrwxrwxrwx 1 root root 33 Aug  1 04:54 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@server1 fonts]# ls
graphfont.ttf  simkai.ttf
[root@server1 fonts]# cd ..
[root@server1 zabbix]# cd include/
[root@server1 include]# vim defines.inc.php 
:%s/graphfont/simkai/g    #将graphfont替换为simkai

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值