在zabbix监控平台添加服务监控项(http,nginx,mysql)

一、添加自带的http监控项

1.在浏览器中给server2添加http的监控项

  • http是zabbix自带的监控模版
  • 配置 —>主机 —> server2 —> 模板 —>选择 —> Template App HTTP Service—> 添加 —>更新
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    点击server2可以看到http服务正在运行
    在这里插入图片描述

二、添加nginx监控

zabbix中没有nginx的监控项,座椅要在agent端部署nginx服务
curl -s http://127.0.0.1/status | grep Active | awk '{print $3}’

1.部署nginx服务并测试

(1)安装nginx的依赖性

[root@server3 ~]# yum install gcc pcre-devel zlib-devel -y

在这里插入图片描述
(2)解压安装包,关闭debug日志,编译安装

[root@server3 ~]# ls
nginx-1.16.0.tar.gz  zabbix-agent-4.0.5-1.el7.x86_64.rpm
[root@server3 ~]# tar zxf nginx-1.16.0.tar.gz    ##解压安装包
[root@server3 ~]# ls
nginx-1.16.0  nginx-1.16.0.tar.gz  zabbix-agent-4.0.5-1.el7.x86_64.rpm
[root@server3 ~]# cd nginx-1.16.0
[root@server3 nginx-1.16.0]# vim auto/cc/gcc    ##关闭debug日志
[root@server3 nginx-1.16.0]# 
[root@server3 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module      
##编译,需要添加http_stub_status_module模块,这是用来金控http状态的

[root@server3 nginx-1.16.0]# make && make install

在这里插入图片描述
在这里插入图片描述
(3)编辑配置文件

[root@server3 nginx-1.16.0]# cd /usr/local/nginx/conf/
[root@server3 conf]# vim nginx.conf

        location /status {
            stub_status on;    ##状态监控开启
            access_log off;    ##不记录状态监控的日志
            allow 127.0.0.1;   ##只允许管理员查看
            deny all;          ##其他的都拒绝
        }

在这里插入图片描述
在这里插入图片描述
(4)语法检测,开启服务

[root@server3 conf]# ../sbin/nginx  -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@server3 conf]# ../sbin/nginx  

在这里插入图片描述
(5)访问测试:

[root@server3 conf]# curl http://127.0.0.1/status
Active connections: 1 
server accepts handled requests
 1 1 1 
Reading: 0 Writing: 1 Waiting: 0 

在这里插入图片描述
(6)安装httpd,模拟访问量

[root@server3 conf]# yum install -y httpd
[root@server3 conf]# ab -c 1 -n 1000 http://127.0.0.1/status

[root@server3 conf]# curl http://127.0.0.1/status

[root@server3 conf]# curl -s  http://127.0.0.1/status
Active connections: 1 
server accepts handled 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值