|
1 | | -# Lab 03 — Advanced Features: zabbix with TLS, resource limits, logging |
| 1 | +# Lab 03 — Advanced Features: Zabbix with Agent2 self-monitoring + resource limits |
| 2 | +# Zabbix Agent2 added for server self-monitoring · extra pollers configured |
| 3 | +# Zabbix Web: http://localhost:8423 (admin / zabbix) |
| 4 | +# Mailhog: http://localhost:8723 |
2 | 5 | --- |
| 6 | +name: it-stack-zabbix-lab03 |
| 7 | + |
3 | 8 | services: |
4 | | - zabbix: |
5 | | - image: zabbix/zabbix-server-pgsql:alpine-6.4-latest |
6 | | - container_name: it-stack-zabbix |
| 9 | + |
| 10 | + # ── External Database ─────────────────────────────────────────────────── |
| 11 | + zabbix-a03-db: |
| 12 | + image: mysql:8.0 |
| 13 | + container_name: zabbix-a03-db |
| 14 | + restart: unless-stopped |
| 15 | + command: --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --default-authentication-plugin=mysql_native_password |
| 16 | + environment: |
| 17 | + MYSQL_ROOT_PASSWORD: RootLab03! |
| 18 | + MYSQL_DATABASE: zabbix |
| 19 | + MYSQL_USER: zabbix |
| 20 | + MYSQL_PASSWORD: ZabbixLab03! |
| 21 | + volumes: |
| 22 | + - zabbix-a03-db-data:/var/lib/mysql |
| 23 | + deploy: |
| 24 | + resources: |
| 25 | + limits: |
| 26 | + cpus: "0.5" |
| 27 | + memory: 512M |
| 28 | + logging: |
| 29 | + driver: json-file |
| 30 | + options: {max-size: "50m", max-file: "3"} |
| 31 | + healthcheck: |
| 32 | + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uzabbix", "-pZabbixLab03!"] |
| 33 | + interval: 10s |
| 34 | + timeout: 5s |
| 35 | + retries: 10 |
| 36 | + start_period: 30s |
| 37 | + networks: |
| 38 | + - zabbix-a03-net |
| 39 | + |
| 40 | + # ── SMTP relay (Mailhog) ───────────────────────────────────────────── |
| 41 | + zabbix-a03-mail: |
| 42 | + image: mailhog/mailhog:latest |
| 43 | + container_name: zabbix-a03-mail |
7 | 44 | restart: unless-stopped |
8 | 45 | ports: |
9 | | - - "10051:$firstPort" |
| 46 | + - "8723:8025" |
| 47 | + networks: |
| 48 | + - zabbix-a03-net |
| 49 | + |
| 50 | + # ── Zabbix Server (extra pollers + resource limits) ─────────────────── |
| 51 | + zabbix-a03-server: |
| 52 | + image: zabbix/zabbix-server-mysql:ubuntu-7.0-latest |
| 53 | + container_name: zabbix-a03-server |
| 54 | + restart: unless-stopped |
| 55 | + depends_on: |
| 56 | + zabbix-a03-db: {condition: service_healthy} |
10 | 57 | environment: |
11 | | - - IT_STACK_ENV=lab-03-advanced |
12 | | - - TLS_ENABLED=true |
| 58 | + DB_SERVER_HOST: zabbix-a03-db |
| 59 | + MYSQL_DATABASE: zabbix |
| 60 | + MYSQL_USER: zabbix |
| 61 | + MYSQL_PASSWORD: ZabbixLab03! |
| 62 | + MYSQL_ROOT_PASSWORD: RootLab03! |
| 63 | + ZBX_TIMEOUT: 30 |
| 64 | + ZBX_STARTPOLLERS: 5 |
| 65 | + ZBX_STARTPINGERS: 3 |
| 66 | + ZBX_STARTDISCOVERERS: 2 |
| 67 | + ZBX_CACHESIZE: 32M |
| 68 | + ZBX_HISTORYCACHESIZE: 16M |
| 69 | + ZBX_TRENDCACHESIZE: 4M |
| 70 | + ports: |
| 71 | + - "10051:10051" |
13 | 72 | volumes: |
14 | | - - zabbix_data:/var/lib/zabbix |
15 | | - - ./certs:/etc/ssl/certs:ro |
| 73 | + - zabbix-a03-alertscripts:/usr/lib/zabbix/alertscripts |
| 74 | + - zabbix-a03-externalscripts:/usr/lib/zabbix/externalscripts |
| 75 | + deploy: |
| 76 | + resources: |
| 77 | + limits: |
| 78 | + cpus: "1.0" |
| 79 | + memory: 1G |
| 80 | + logging: |
| 81 | + driver: json-file |
| 82 | + options: {max-size: "100m", max-file: "5"} |
| 83 | + healthcheck: |
| 84 | + test: ["CMD-SHELL", "zabbix_server --version > /dev/null 2>&1 && echo ok || exit 1"] |
| 85 | + interval: 30s |
| 86 | + timeout: 15s |
| 87 | + retries: 5 |
| 88 | + start_period: 90s |
| 89 | + networks: |
| 90 | + - zabbix-a03-net |
| 91 | + |
| 92 | + # ── Zabbix Web Frontend ────────────────────────────────────────────── |
| 93 | + zabbix-a03-web: |
| 94 | + image: zabbix/zabbix-web-nginx-mysql:ubuntu-7.0-latest |
| 95 | + container_name: zabbix-a03-web |
| 96 | + restart: unless-stopped |
| 97 | + depends_on: |
| 98 | + zabbix-a03-db: {condition: service_healthy} |
| 99 | + zabbix-a03-server: {condition: service_started} |
| 100 | + environment: |
| 101 | + ZBX_SERVER_HOST: zabbix-a03-server |
| 102 | + ZBX_SERVER_PORT: "10051" |
| 103 | + DB_SERVER_HOST: zabbix-a03-db |
| 104 | + MYSQL_DATABASE: zabbix |
| 105 | + MYSQL_USER: zabbix |
| 106 | + MYSQL_PASSWORD: ZabbixLab03! |
| 107 | + PHP_TZ: UTC |
| 108 | + ZBX_SERVER_NAME: "IT-Stack Zabbix Lab03" |
| 109 | + ports: |
| 110 | + - "8423:8080" |
| 111 | + deploy: |
| 112 | + resources: |
| 113 | + limits: |
| 114 | + cpus: "0.5" |
| 115 | + memory: 512M |
| 116 | + logging: |
| 117 | + driver: json-file |
| 118 | + options: {max-size: "50m", max-file: "3"} |
| 119 | + healthcheck: |
| 120 | + test: ["CMD-SHELL", "curl -sf http://localhost:8080/ | grep -qi 'zabbix\\|login' || exit 1"] |
| 121 | + interval: 30s |
| 122 | + timeout: 15s |
| 123 | + retries: 8 |
| 124 | + start_period: 120s |
| 125 | + networks: |
| 126 | + - zabbix-a03-net |
| 127 | + |
| 128 | + # ── Zabbix Agent 2 (self-monitoring — new in Lab 03) ───────────────── |
| 129 | + zabbix-a03-agent: |
| 130 | + image: zabbix/zabbix-agent2:ubuntu-7.0-latest |
| 131 | + container_name: zabbix-a03-agent |
| 132 | + restart: unless-stopped |
| 133 | + depends_on: |
| 134 | + zabbix-a03-server: {condition: service_started} |
| 135 | + environment: |
| 136 | + ZBX_HOSTNAME: "zabbix-a03-server" |
| 137 | + ZBX_SERVER_HOST: zabbix-a03-server |
| 138 | + ZBX_SERVER_PORT: "10051" |
| 139 | + ZBX_PASSIVE_ALLOW: "true" |
| 140 | + ZBX_ACTIVE_ALLOW: "true" |
16 | 141 | deploy: |
17 | 142 | resources: |
18 | 143 | limits: |
19 | | - cpus: "2.0" |
20 | | - memory: G |
| 144 | + cpus: "0.25" |
| 145 | + memory: 128M |
21 | 146 | logging: |
22 | 147 | driver: json-file |
23 | | - options: |
24 | | - max-size: "100m" |
25 | | - max-file: "5" |
| 148 | + options: {max-size: "20m", max-file: "3"} |
26 | 149 | networks: |
27 | | - - it-stack-net |
| 150 | + - zabbix-a03-net |
28 | 151 |
|
29 | 152 | networks: |
30 | | - it-stack-net: |
| 153 | + zabbix-a03-net: |
31 | 154 | driver: bridge |
32 | 155 |
|
33 | 156 | volumes: |
34 | | - zabbix_data: |
| 157 | + zabbix-a03-db-data: |
| 158 | + zabbix-a03-alertscripts: |
| 159 | + zabbix-a03-externalscripts: |
0 commit comments