使用docker-compose 快速构建Zabbix监控

Publish: June 25, 2022 Category: 运维 No Comments

全是干货
直接上docker-composer.yml文件

version: '3.3'
services:
postgres-server:

container_name: postgres-server
image: postgres:13.0-alpine
restart: always
environment:
  POSTGRES_USER: zabbix
  POSTGRES_PASSWORD: passwd!Q
  POSTGRES_DB: zabbix
  PG_DATA: /var/lib/postgresql/data/pgdata

zabbix-server:

container_name: zabbix-server
image: zabbix/zabbix-server-pgsql:ubuntu-5.4.9
restart: always
environment:
  POSTGRES_USER: zabbix
  POSTGRES_PASSWORD: passwd!Q
  POSTGRES_DB: zabbix
  ZBX_HISTORYSTORAGETYPES: log,text
  ZBX_DEBUGLEVEL: 1
  ZBX_HOUSEKEEPINGFREQUENCY: 1
  ZBX_MAXHOUSEKEEPERDELETE: 5000
depends_on:
  - postgres-server
volumes:
  - ./volumes/zabbix/alertscripts:/usr/lib/zabbix/alertscripts

zabbix-frontend:

container_name: zabbix-frontend
image: zabbix/zabbix-web-nginx-pgsql:ubuntu-5.4.9
restart: always
ports:
  - '8080:8080'
environment:
  POSTGRES_USER: zabbix
  POSTGRES_PASSWORD: passwd!Q
  POSTGRES_DB: zabbix
  ZBX_SERVER_HOST: zabbix-server
  ZBX_POSTMAXSIZE: 64M
  PHP_TZ: "Asia/Shanghai"
  ZBX_MAXEXECUTIONTIME: 500
depends_on:
  - postgres-server
  - zabbix-server

zabbix-agent:

container_name: zabbix-agent
image: zabbix/zabbix-agent:latest
privileged: true
restart: unless-stopped
environment:
  - ZBX_SERVER_HOST=zabbix-server

使用docker-compose命令

docker-compose up --build -d

这样启动三个docker容器

  • zabbix-frontend
  • zabbix-server
  • zabbix-agent

都启动成,在浏览器端访问: http://hostname:8080/ 默认用户名密码 Admin zabbix

在被监控主机安装 zabbix-agent

apt install zabbix-agent

安装成功后配置文件修改:
/etc/zabbix/zabbix_agentd.conf

Server:  ZabbixServer地址(被动模式)
ServerActive: ZabbixServer地址 (主动模式)
HostName: 主机名

配置完成之后重启:

/etc/init.d/zabbix-agent restart

之后回到Server的web管理界面,按要求添加主机即可