Zabbix高级监控功能
2020-09-04 本文已影响0人
想成为大师的学徒小纪
一、自动发现监控主机
1、设置自动发现


2、设置动作





3、通过检测功能查看是否成功

二、自动注册监控主机
1、修改客户端配置文件
vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.16.1.8
ServerActive=172.16.1.8
Hostname=web01
HostMetadata=web
RefreshActiveChecks=60
Include=/etc/zabbix/zabbix_agentd.d/*.conf
2、重启客户端服务
systemctl restart zabbix-agent
3、进入zabbix网页进行配置




4、检测主机已连接

三、web检测设置
以监控Zabbix首页是否正常,用户登录是否正常为例
1、获取登录认证数据
登录Zabbix网页通过账号密码进入首页,使用开发者工具查看

2、创建web检测场景





3、检查是否有数据

4、设置触发器




四、mysql监控设置
1、数据库客户端安装percona软件
rpm -ivh https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
2、修改软件php取值脚本
cd /var/lib/zabbix/percona/scripts
vim ss_get_mysql_stats.php
$mysql_user = 'root';
$mysql_pass = '123456';
3、修改软件shell脚本
cd /var/lib/zabbix/percona/scripts
vim get_mysql_stats_wrapper.sh
RES=`HOME=~zabbix mysql -u root -p123456 -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`
4、复制自定义监控项配置文件
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
5、重启客户端服务
systemctl restart zabbix-agent
6、将模板文件导入zabbix网页
软件自带的/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml文件有问题,要使用其他



==Zabbix服务端安装jq软件,否则会报cannot convert value to numeric type==
yum -y install jq
7、将模板添加到数据库主机,查看最新数据

五、Zabbix Proxy设置
1、代理服务器安装Zabbix Proxy服务
yum -y install zabbix-proxy mariadb-server
2、创建数据库账号密码
systemctl start mariadb
mysqladmin -u root password '123456'
mysql -u root -p123456
create database zabbix_proxy character set utf8 collate utf8_bin;
create user zabbix_proxy@localhost identified by 'zabbix_proxy';
grant all privileges on zabbix_proxy.* to zabbix_proxy@localhost;
flush privileges;
3、 导入初始架构和数据
zcat /usr/share/doc/zabbix-proxy-mysql-4.0.24/schema.sql.gz|mysql -uzabbix_proxy -pzabbix_proxy zabbix_proxy
4、修改proxy配置文件
vim /etc/zabbix/zabbix_proxy.conf
ProxyMode=0 #声明这台是代理服务器
Server=172.16.1.71 #服务端IP地址
ServerPort=10051 #服务端端口
Hostname=web03 #代理服务器主机名
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=zabbix_proxy
ConfigFrequency=30 #每30秒一次主动去server端拉取最新的配置
DataSenderFrequency=10 #每10秒发送采集的监控数据到服务器端
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
5、启动proxy服务
systemctl start zabbix-proxy
6、修改客户端文件
vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.16.1.9 #代理服务器地址
ServerActive=172.16.1.9
Hostname=web01
HostMetadata=web
RefreshActiveChecks=60
Include=/etc/zabbix/zabbix_agentd.d/*.conf
7、重启客户端服务
systemctl restart zabbix-agent
8、进入zabbix网页进行配置


9、设置自动注册


10、查看是否成功

