Zabbix简介
Zabbix概述
Zabbix 是一款可监控网络的众多参数以及服务器、虚拟机、应用程序、服务、数据库、网站、云等的健康状况和完整性。Zabbix 使用灵活的通知机制,允许用户为几乎任何事件配置基于电子邮件的警报。这允许对服务器问题做出快速反应。Zabbix 基于存储的数据提供报告和数据可视化功能。这使得 Zabbix 成为容量规划的理想选择。
Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。
zabbix特性
1.数据收集
- 可用性和性能采集;
- 支持 SNMP(包括主动轮询和被动捕获)、IPMI、JMX、VMware 监控;
- 自定义检查;
- 按照自定义的时间间隔采集需要的数据;
- 通过 Server/Proxy 和 Agents 来执行数据采集。
2.灵活的阈值定义
您可以定义非常灵活的告警阈值,称之为触发器,触发器从后端数据库获得参考值。
3.高度可配置化告警
- 可以根据递增计划、接收者、媒介类型自定义发送告警通知;
- 使用宏变量可以使告警通知变得更加高效有益;
- 自动动作包含远程命令。
4.实时绘图
使用内置图形功能可实以将监控项绘制成图形。
5.WEB监控功能
Zabbix 可以追踪模拟鼠标在 Web 网站上的点击操作,来检查 Web 网站的功能和响应时间。
6.丰富的可视化选项
- 能够创建可以将多个监控项组合到单个视图中的自定义图形;
- 网络拓扑图;
- 以仪表盘样式展示自定义聚合图形和幻灯片演示;
- 报表;
- 监控资源的高层次(业务)视图。
7.历史数据存储
- 存储在数据库中的数据;
- 可配置的历史数据;
- 内置数据管理机制(housekeeping)
8.易配置
- 将被监控设备添加为主机;
- 主机一旦添加到数据库中,就会采集主机数据用于监控;
- 将模板用于监控设备。
9.模板功能
- 在模板中分组检查;
- 模板可以关联其他模板,获得继承。
10.网络发现
- 自动发现网络设备;
- Zabbix Agent 发现设备后自动注册;
- 自动发现文件系统、网络接口和 SNMP OIDs 值。
11.页面展示
- 基于 PHP 的 Web 前端;
- 可以从任何地方访问;
- 您可以定制自己的操作方式;
- 审计日志。
12. zabbix api
Zabbix API 为 Zabbix 提供可编程接口,用于批量操作、第三方软件集成和其他用途。
13.权限系统
- 安全的用户身份验证;
- 将特定用户限制于访问特定的视图。
14.易扩展
- 部署于被监控对象上;
- 完美支持 Linux 和 Windows ;
15.二进制守护进程
- 为了更好的性能和更少的内存占用,采用 C 语言编写;
- 便于移植。
16.适用复杂网络环境
使用 Zabbix Proxy 代理,可以轻松实现分布式远程监控。
Zabbix 基础架构
zabbix server
zabbix server 是整个 Zabbix 软件的核心程序。
Zabbix Server 负责执行数据的主动轮询和被动获取,计算触发器条件,向用户发送通知。它是 Zabbix Agent 和 Proxy 报告系统可用性和完整性数据的核心组件。Server 自身可以通过简单服务远程检查网络服务(如Web服务器和邮件服务器)。
Zabbix Server是所有配置、统计和操作数据的中央存储中心,也是Zabbix监控系统的告警中心。在监控的系统中出现任何异常,将被发出通知给管理员。
基本的 Zabbix Server 的功能分解成为三个不同的组件。他们是:Zabbix server、Web前端和数据库。
Zabbix 的所有配置信息都存储在 Server 和Web前端进行交互的数据库中。例如,当你通过Web前端(或者API)新增一个监控项时,它会被添加到数据库的监控项表里。然后,Zabbix server 以每分钟一次的频率查询监控项表中的有效项,接着将它存储在 Zabbix server 中的缓存里。这就是为什么 Zabbix 前端所做的任何更改需要花费两分钟左右才能显示在最新的数据段的原因。
Zabbix agent
Zabbix agent 部署在被监控目标上,以主动监控本地资源和应用程序(硬盘、内存、处理器统计信息等)。
Zabbix agent 收集本地的操作信息并将数据报告给 Zabbix server 用于进一步处理。一旦出现异常 (例如硬盘空间已满或者有崩溃的服务进程),Zabbix server 会主动警告管理员指定机器上的异常。
Zabbix agents 的极高效率缘于它可以利用本地系统调用来完成统计数据的采集。
Zabbix部署
集群机器准备
(建议≥2台)
*主机名* | 内网IP | 外网IP | 系统 | *服务* |
*zabbix_server* | 172.28.54.185 | 8.130.31.182 | CentOS8.3 | zabbix-server、zabbix-agent、MySQL、zabbix-web |
*zabbix_agent01* | 172.28.54.186 | 8.130.162.128 | CentOS8.3 | zabbix-agent |
*zabbix_agent02* | 172.28.54.187 | 8.130.31.230 | CentOS8.3 | zabbix-agent |
准备工作
- 查看检查服务器系统版本环境
- 关闭防火墙(所有节点)
- 关闭SELinux , 修改/etc/selinux/config文件(所有节点)
zabbix官网
- zabbix官网
https://www.zabbix.com/ 点击download,根据情况选择好需求,yum源安装方式,页面下方会生成对应安装命令
【注意: 】 本次部署采用的是Zabbix Packages安装,yum源需要网络连通,此方式不适合被网络隔离且没有代理网络的内网环境,网络受限的情况需要去采用容器或者ZabbixSources源码安装更适合;源码安装在下载项旁边有部署文档连接
官网给了不同的下载方式,根据需要选择下载即可,下方会有安装简要
官方文档说明: https://www.zabbix.com/documentation/current/manual/definitions
安装部署
- 安装zabbix官方yum源(所有节点先配置好yum源,后续操作均为server)
- 安装Zabbix server,Web前端,agent
- 安装数据库mariadb
- 创建初始数据库
- 导入初始架构和数据,系统将提示您输入新创建的密码
- 为Zabbix server配置数据库,修改/etc/zabbix/zabbix_server.conf
- 为Zabbix前端nginx配置PHP
- 修改前端显示时区
- 启动服务zabbix-server zabbix-agent nginx php-fpm
访问初始化配置
浏览器访问server ip
选择中文 - 下一步 -
配置DB连接(端口和密码根据情况填写)
都点击下一步,完成安装
登录:
用户名:Admin
密码:zabbix
至此最新版本zabbix5.4的server就已经部署完毕
增加agent监控节点
界面添加主机( 添加完agent01后,克隆一下换agent02的ip即可)
等待agent成功被发现监控后查看页面
点击主机,选择图形;可以查看常规指数图形 (管理中一般设置可以更改主题风格)
监控使用介绍
案例: 监控某个端口是否异常
首先在服务器上启动一个测试端口 6666
选择配置 - 主机 - 选择zabbix-server节点 - 右上角创建监控项
键值 : net.tcp.listen[port] 检查 TCP 端口 是否处于侦听状态。返回 0 - 未侦听;1 - 正在侦听 把port换成实际需要监控的端口 添加
有了监控项也就具备了持续监控状态,还需要一个状态变化触发告警的配置:触发器
在表达式中点击添加,选择 匹配上我们配置的监控项:httpd_6666端口监控 插入即可
现在把httpd服务禁用
等待一会查看仪表盘:
可以看到,监控告警已经报告了对应监控项
回到服务器命令行,重新运行服务,模拟修复故障
这时候可以看到告警项已经不再告警
可以在监测项中查看问题,有问题历史记录
到此,相当于流程 定义监控 - 发现问题抛出告警 - 相关人员处理问题 - 监控告警状态解除 已经完毕