目录
[三、zabbix 安装步骤](#三、zabbix 安装步骤)
一、什么是Zabbix
●zabbix 是一个基于 Web 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
●zabbix 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
●zabbix 由 2 部分构成,zabbix server 与可选组件 zabbix agent。通过 C/S 模式采集数据,通过 B/S 模式在 Web 端展示和配置。
●zabbix server 可以通过 zabbix agent,SNMP协议,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在 Linux 等平台上。
●zabbix agent 需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU 等信息的收集。
二、zabbix监控原理
zabbix agent 安装在被监控的主机上,zabbix agent 负责定期收集客户端本地各项数据,并发送至 zabbix server 端,zabbix server 收到数据后, 将数据存储到数据库中,用户基于 Zabbix Web 可以看到数据在前端展现图像。当 zabbix 监控某个具体的项目, 该项目会设置一个触发器阈值, 当被监控的指标超过该触发器设定的阈值,会进行一些必要的动作,动作包括:发送信息(邮件、微信、短信)、发送命令(shell 命令、reboot、restart、 install 等)。
三、zabbix 安装步骤
导入nginx源
安装nginx

导入PHP源

然后编辑vim /etc/yum.repos.d/local.repo
编辑内容如下




vim /etc/nginx/conf.d/default.conf 修改

vim /etc/php-fpm.d/www.conf 修改

vim /etc/php.ini 编辑
max_execution_time = 300 # 368行
max_input_time = 600 # 378行
post_max_size = 80M # 656行
date.timezone = Asia/Shanghai # 877行
编辑 vim /usr/share/nginx/html/index.php 就是编辑vim /etc/nginx/conf.d/default.conf 配置里的路径
保存退出 然后启动服务systemctl enable --now nginx php-fpm
然后打开网页看看有没有PHP

然后装数据库源 下载数据库


分别输入 回车 -> n -> Y (设置root密码,如abc123) -> 后面一路 Y



//编译安装 zabbix Server 服务端
#安装依赖包,创建 zabbix 用户
yum install -y mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel fping gcc gcc-c++ make

./configure \
--sysconfdir=/etc/zabbix/ \
--enable-server \
--with-mysql \
--with-net-snmp \
--with-libxml2 \
--with-ssh2 \
--with-openipmi \
--with-zlib \
--with-libpthread \
--with-libevent \
--with-openssl \
--with-ldap \
--with-libcurl \
--with-libpcre
然后安装 make install

vim /etc/zabbix/zabbix_server.conf 编辑


然后保存退出


然后浏览器登录


密码就是zabbix

主机名自己取



安装完成后,默认的登录账号和密码为:Admin/zabbix

此时就进入界面了


然后安装客户端自我监控
导入相关的yum源 然后安装agent2

安装完后开启服务 查看端口

然后图形界面有乱码问题

yum install -y wqy-microhei-fonts安装这个
\cp -f /usr/share/fonts/wqy-microhei/wqy-microhei.ttc/usr/share/nginx/html/assets/fonts/DejaVuSans.ttf
刷新解决乱码问题

在监控一台机器
第一步却保时间同步

vim /etc/hosts 编辑 把服务端跟客户端都写进去

然后20.0.0.101 也需要
//设置 zabbix 的下载源,安装 zabbix-agent2
rpm -ivh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm
sed -i 's#https://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum install -y zabbix-agent2
然后启动服务
vim /etc/zabbix/zabbix_agent2.conf 编辑
下面这两个都把ip设置成服务端的ip



保存退出
然后

重启systemctl restart zabbix-agent2.service
在20.0.0.100服务端安装

测试连通信
返回表示联通
然后去配置主机


然后点击添加
此时就有了 等待小绿灯亮 就表示服务端接收到监控数据了 大概等待一分钟

自定义监控模板 (模拟限制登录人数不超过 3 个,超过 3 个就发出报警信息
)
到20.0.0.101 客户端 cd /etc/zabbix/zabbix_agent2.d/
创建一个模板 名字自取 .conf结尾就行 然后编辑内容

保存退出重启 systemctl restart zabbix-agent2
然后到服务端 验证键行不行

此时说明配置对的
然后配置自定义模板
1.创建模板
点击左边菜单栏【配置】中的【模板】,点击【创建模板】
【模板名称】设置成 xxx
【可见的名称】设置成 xxx
【群组】选择 Template
【描述】可自定义
点击 【添加】,此时就可在【名称】xxx 中搜索到 了

输入模板名字就可以搜到了

然后点击进去

就能看到模板 然后点击监控项

点击创建监控项



然后配置触发器

进入后点击创建触发器





添加图形步骤和上面一样

然后到主机 找到客户端 点击进去 添加模板 更新


然后我现在是3个用户 超过我设置的2个的值了所以告警了
