docker-compose.yml安装zabbix
定义docker-compose.yml文件
/usr/local/docker4zabbix/docker-compose.yml
version: "3" #定义类型为 3 services: mysql3306: image: registry.cn-hangzhou.aliyuncs.com/mysql_dreasky/mysql restart: always ports: - "3306:3306" container_name: mysql3306 command: --character-set-server=utf8 #定义字符集 environment: MYSQL_ROOT_PASSWORD: mysqlpasswd #定义mysql root密码 MYSQL_DATABASE: zabbix # 创建数据库 MYSQL_USER: zabbix #定义用户 MYSQL_PASSWORD: 123456 #用户密码 volumes: - /data/mysql3306:/var/lib/mysql - /etc/localtime:/etc/localtime:ro zabbix-server: image: registry.cn-hangzhou.aliyuncs.com/zabbix_dreasky/zabbix-server-mysql ports: - "10051:10051" #声明端口 environment: DB_SERVER_HOST: 172.21.23.33 #连接mysql DB_SERVER_PORT: 3306 # 连接端口 MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: 123456 volumes: - ./zabbix_server/alertscripts/dingding.sh:/usr/lib/zabbix/alertscripts/dingding.sh #钉钉告警脚本 - /etc/localtime:/etc/localtime zabbix-web: image: registry.cn-hangzhou.aliyuncs.com/zabbix_dreasky/zabbix-web-apache-mysql #镜像 ports: - "8080:8080" #声明端口 environment: DB_SERVER_HOST: 172.21.23.33 #连接mysql DB_SERVER_PORT: 3306 # 连接端口 MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: 123456 PHP_TZ: Asia/Shanghai #声明时区为亚洲/上海 ZBX_SERVER_HOST: zabbix-server volumes: - ./zabbix_server/php/fonts/DejaVuSans.ttf:/usr/share/zabbix/assets/fonts/DejaVuSans.ttf #解决图形中文乱码字体 - /etc/localtime:/etc/localtime
钉钉告警脚本
/usr/local/docker4zabbix/zabbix_server/alertscripts/dingding.sh
#!/bin/bash to=$1 subject=$2 text=$3 #此处的 xxxxx 就是刚刚复制存留的 api 接口地址。 curl -i -X POST \ 'https://oapi.dingtalk.com/robot/send?access_token=XXX' \ -H 'Content-type':'application/json' \ -d ' { "msgtype": "text", "text": { "content": "'监控报警:''"$text"'" }, "at":{ "atMobiles":[ "'"$1"'" ], "isAtAll":false } }'
字体路径:
把Windows系统中的字体(如黑体 常规 simhei.ttf)上传到/usr/local/docker4zabbix/zabbix_server/php/fonts/目录下,重命名成 DejaVuSans.ttf
mv simhei.ttf DejaVuSans.ttf
启动docker
docker-compose up -d
访问:http:172.21.23.33:8080
默认用户名/密码:Admini/zabbix