标签:nsa 组合 htm zab dex nec static order 编写
一、准备环境
主机 | 名称 |
192.168.200.113 | agent.zabbix.com |
1、关闭防火墙和安全机制
[root@agent ~]# systemctl stop firewalld [root@agent ~]# setenforce 0 [root@agent ~]# iptables -F
二、安装nginx(已有自己组合的包,直接安装)
1、安装
[root@agent ~]# rpm -ivh nginx-1.15.9-1.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:nginx-1.15.9-1 ################################# [100%]
[root@agent ~]# nginx -V nginx version: nginx/1.15.9 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module
2、修改配置文件
[root@agent ~]# vim /usr/local/nginx/conf/nginx.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; #stub_status on; #access_log off; } location /status { stub_status on; access_log off; } #error_page 404
[root@agent ~]# killall -HUP nginx //平滑重启
3、网页测试
4、编写zabbix监控nginx的脚本
[root@agent ~]# vim /usr/local/zabbix/scripts/nginx-check.sh
[root@agent ~]# chmod +x /usr/local/zabbix/scripts/nginx-check.sh
5、配置agent.conf文件
[root@agent ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf PidFile=/tmp/zabbix_agentd.pid Server=192.168.200.112 ServerActive=192.168.200.112 Hostname=agent.zabbix.com LogFile=/usr/local/zabbix/logs/zabbix_agentd.log Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf UnsafeUserParameters=1 UserParameter=mysql.version,mysql -V UserParameter=mysql.status[*],/usr/local/zabbix/etc/chk_mysql.sh $1 UserParameter=mysql.ping,mysqladmin -uroot -p123123 -P3306 -h192.168.200.113 ping | grep -c alive UnsafeUserParameters=1 UserParameter=nginx[*],/usr/local/zabbix/scripts/nginx-check.sh "$1"
6、重新启动
[root@agent ~]# /etc/init.d/zabbix_agentd restart Zabbix agent terminated. Zabbix agent started. [root@agent ~]# netstat -anpt | grep 10050 tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 27812/zabbix_agentd
7、server端(192.168.200.112)测试获取数据
在获取数据之前server端必须安装wget
[root@agent ~]# yum -y install wget
agent端访问
[root@server ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.113 -p 10050 -k "nginx[reading]" 0 [root@server ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.200.113 -p 10050 -k "nginx[writing]" 1
三、创建监控测试
选择模板文件导入,导入后就可以使用了
有图像说明成功了
标签:nsa 组合 htm zab dex nec static order 编写
原文地址:https://www.cnblogs.com/tanxiaojuncom/p/11799984.html