Zabbix分布式监控平台部署<3>–zabbix-nginx部署及字体修正
1.zabbix-nginx部署
1.nginx源码编译、安装、配置
[root@server2 ~]# tar zxf nginx-1.20.1.tar.gz(官网下载)
[root@server2 ~]# ls
lamp nginx-1.20.1 nginx-1.20.1.tar.gz
[root@server2 ~]# cd nginx-1.20.1
[root@server2 nginx-1.20.1]# ls #源码安装时解压目录中的初始文件
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README
[root@server2 nginx-1.20.1]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module #编译指令,--with-http_stub_status_module:必须添加的模块
[root@server2 nginx-1.20.1]# yum install gcc -y ##编译需要c语言包
[root@server2 nginx-1.20.1]# yum install pcre-devel -y ##http重写功能需要的包
[root@server2 nginx-1.20.1]# yum install -y openssl-devel ##ssl功能需要的包
[root@server2 nginx-1.20.1]# make & make install ##安装
[root@server2 ~]# vim .bash_profile ##注意路径(/root/下)
内容:PATH=$PATH:$HOME/bin:/usr/local/nginx/sbin
[root@server2 ~]# source .bash_profile ##使上述更改生效
[root@server2 ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/ ##创建软连接,相当于创建环境变量
[root@server2 ~]# nginx -t ##语法检测
[root@server2 ~]# nginx ##开启
[root@server2 ~]# 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 }
[root@server2 ~]# nginx -s reload
2.zabbix对nginx服务器的监控部署
nginx服务器(server2):
[root@server2 conf]# 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]# ls
userparameter_mysql.conf userparameter_nginx.conf
[root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf
16 UserParameter=nginx.active,curl -s http://localhost/status | grep Active | awk '{print $3}'
17 UserParameter=nginx.accept,curl -s http://localhost/status | awk 'NR==3{print $1}'
18 UserParameter=nginx.handle,curl -s http://localhost/status | awk 'NR==3{print $2}'
19 UserParameter=nginx.request,curl -s http://localhost/status | awk 'NR==3{print $3}'
[root@server2 zabbix_agentd.d]# systemctl restart zabbix-agent.service
Zabbix sevrer 端:
[root@server1 ~]# yum install zabbix-get
[root@server1 ~]# zabbix_get -s 172.25.6.2 -p 10050 -k "nginx.accept"
1244
[root@server1 ~]# zabbix_get -s 172.25.6.2 -p 10050 -k "nginx.handle"
1245
[root@server1 ~]# zabbix_get -s 172.25.6.2 -p 10050 -k "nginx.request"
1248
[root@server1 ~]# zabbix_get -s 172.25.6.2 -p 10050 -k "nginx.active “
1
3、网页配置
4、字体修正
由于字体插件的问题,导致zabbix监控图形出现乱码情况,所以需要安装的字体,可以通过软连接的方法实现
[root@server1 ~]# cd /usr/share/zabbix
[root@server1 zabbix]# cd fonts/
[root@server1 fonts]# ls
graphfont.ttf
[root@server1 fonts]# cp /root/simkai.ttf (网络下载)
[root@server1 fonts]# ls
graphfont.ttf simkai.ttf
[root@server1 fonts]# rm -fr graphfont.ttf
[root@server1 fonts]# ln -s simkai.ttf graphfont.ttf