Zabbix

学习手册

https://www.zabbix.com/documentation/4.0/zh/manual

 安装zabbix

1、前端安装的先决条件

rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-proxy-mysql zabbix-web-mysql -y

2、安装mysql并配置

create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to 'zabbix'@'%'  identified by "zabbix";
flush privileges;

3、导入数据

zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -u zabbix -h 192.168.88.10 -p zabbix

 4、修改配置文件

[root@localhost zabbix-server-mysql-4.4.10]# grep -E '^[^#]' /etc/zabbix/zabbix_server.conf
ListenPort=10051
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=192.168.88.10
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

5、启动zabbix

systemctl start zabbix-server.service
systemctl enable zabbix-server.service

6、Zabbix 前端配置

取消 "date.timezone" 注释,并为其设置正确的时区 
[root@localhost zabbix-server-mysql-4.4.10]#vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl restart zabbix-server.service
systemctl start httpd.service
systemctl enable httpd.service

访问 http://192.168.88.10/zabbix

 

 

 登录初始账号密码 Admin:zabbix

解决问题

[root@localhost ~]# zabbix_server -V
zabbix_server (Zabbix) 4.4.10
rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.10-1.el7.x86_64.rpm
[root@localhost ~]# grep -E '^[^#]' /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.88.10
ListenPort=10050
ListenIP=0.0.0.0
ServerActive=127.0.0.1
Hostname=test-10
Include=/etc/zabbix/zabbix_agentd.d/*.conf
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service

修改主机ip

更新后等待几分钟

 

结果

 

 监控

1、监控test-20,在test-20安装agent

[root@test-20 src]# rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.10-1.el7.x86_64.rpm

2、修改配置文件填写zabbix服务器的ip然后启动agent

[root@test-20 src]# grep -E '^[^#]' /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.88.10
ListenPort=10050
ListenIP=0.0.0.0
ServerActive=192.168.88.10
Hostname=test-20
Include=/etc/zabbix/zabbix_agentd.d/*.conf
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service

3、点击配置-主机,创建主机

4、选择-添加-更新模板

 

 5、监控客户端httpd是否存活

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.d/key.conf
UserParameter=port.status[*],ss -an | grep -w $1
systemctl restart zabbix-agent.service

 6、设置映射值

 

 7、添加监控项

 8、添加触发器

 9、添加邮箱

 登录qq邮箱设置

 复制授权码

把授权码粘贴到密码

 选择用户添加报警媒介

 选择发给那个邮箱

修改报警信息

 

启用

 测试

 

 

10、设置动作

在客户端修改配置,允许远程执行命令

[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
EnableRemoteCommands=1

提高客户端zabbix用户的权限

[root@localhost ~]# visudo
zabbix  ALL=(ALL)       NOPASSWD: ALL
systemctl restart zabbix-agent.service

设置动作为尝试重启后发送邮件

 

 

 测试

 故障自动解决

 Web检测

 

 

 

 

 

 自动注册+主动模式

设置监控项为主动模式,应先全克隆模板

 

 

 

 

 自动注册

修改test-20配置文件

[root@test-20 promethus]# grep -E '^[^#]' /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.88.30
ListenPort=10050
ListenIP=0.0.0.0
ServerActive=192.168.88.30
Hostname=test-20
Include=/etc/zabbix/zabbix_agentd.d/*.conf
systemctl restart zabbix-agent.service

 

 

 

 

 仍然可以获取数据

 

posted @ 2022-10-13 19:08  kivtx  阅读(141)  评论(0)    收藏  举报