一、通过Zabbix分布式监控平台添加服务监控选项(http,nginx,mysql)
一.添加http服务监控项
http是zabbix自带的监控模板
-
依次进行选择:配置->主机->server2->模板->链接指示器->Template App HTTP Service->添加->更新
-
最后再次点击主机时,会发现此时的server2中显示监控项模板中有Template App HTTP Service
二.监控nginx服务
因为server中有http,所以这里要在server3中重新搭建一个nginx
原理:user->webui->zabbix-agent->shell->zabbix-server->mysql->web
(一)配置nginx
1.在server3上配置nginx[root@server3 ~]# ls
[root@server3 ~]# tar zxf nginx-1.16.0.tar.gz
[root@server3 ~]# cd nginx-1.16.0
[root@server3 nginx-1.16.0]# vim auto/cc/gcc
[root@server3 nginx-1.16.0]# yum install pcre-devel gcc zlib-devel -y
[root@server3 nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
[root@server3 nginx-1.16.0]# make && make install
2.编辑nginx配置文件,检测是否有错,如果没有报错,开启nginx服务
[root@server3 nginx-1.16.0]# cd /usr/local/nginx/conf/
[root@server3 conf]# vim nginx.conf
[root@server3 conf]# ../sbin/nginx -t
[root@server3 conf]# ../sbin/nginx
配置文件的内容如下:
47 location /status {
48 stub_status on; #此模块主要用于查看nginx的一些状态信息
49 access_log off; #关闭日志记录
50 allow 127.0.0.1; #只允许本机访问
51 deny all;
52 }
3.测试(证明nginx配置成功,会显示默认发布页):
[root@server3 conf]# curl 172.25.66.3
(二)监控连接数
1.访问http://127.0.0.1/status,会发现此时连接数等较小,此时需要再次访问本机即可增加连接数等(可以通过查看连接数,也可以通过直接访问ip)
[root@server3 conf]# curl http://127.0.0.1/status
#增加1
[root@server3 conf]# curl 127.0.0.1
#增加1
[root@server3 conf]# curl http://127.0.0.1/status
注意:
(1)此处查看连接数时不可以输入127.25.66.3,即本机的ip
(2)访问时显示活跃连接数1个,server接收请求数,保持的主机数(获取建立三次握手的次数),请求次数
2.为了可以大幅度增加访问请求数等,我们需要利用ab命令增加
#下载httpd的主要原因是要时用命令ab
[root@server3 conf]# yum install httpd -y
[root@server3 conf]# curl http://127.0.0.1/status
3.利用查看连接数并将其放至userparameter_nginx.conf文件下
[root@server3 conf]# curl -s http://127.0.0.1/status | grep Active | awk '{pr