# ============================================================================= # 可选叠加文件:docker compose 启动时自动执行「Zabbix 自监控-only」清理 # # 作用:等 API 就绪后,把「Zabbix server」自身主机上的 "Linux by Zabbix agent" # 模板摘除(只保留 "Zabbix server health" 自监控),避免本机没装 agent 时 # 对自身 10050 的无效连接与告警。幂等,重复 up 安全。 # # 用法: # docker compose -f docker-compose.yaml -f bootstrap/docker-compose.bootstrap.yaml up -d # 手动重跑一次: # docker compose -f docker-compose.yaml -f bootstrap/docker-compose.bootstrap.yaml run --rm zbx-bootstrap # # 认证:默认用 Admin/zabbix 登录;生产建议在 .env 里设置 ZBX_API_TOKEN(API Token)。 # ============================================================================= services: zbx-bootstrap: image: python:3.12-slim container_name: zbx-bootstrap restart: "no" depends_on: zabbix-server: condition: service_started zabbix-web-nginx-mysql: condition: service_started environment: ZBX_API_URL: ${ZBX_API_URL:-http://zabbix-web-nginx-mysql:8080/api_jsonrpc.php} ZBX_API_USER: ${ZBX_API_USER:-Admin} ZBX_API_PASSWORD: ${ZBX_API_PASSWORD:-zabbix} ZBX_API_TOKEN: ${ZBX_API_TOKEN:-} ZBX_HEALTH_TEMPLATE: ${ZBX_HEALTH_TEMPLATE:-Zabbix server health} ZBX_AGENT_TEMPLATE: ${ZBX_AGENT_TEMPLATE:-Linux by Zabbix agent} ZBX_WAIT_SECONDS: ${ZBX_WAIT_SECONDS:-300} volumes: - ./bootstrap/zbx-bootstrap.py:/app/zbx-bootstrap.py:ro command: ["python3", "/app/zbx-bootstrap.py"] networks: - zabbix