Skip to content

Commit 4dac085

Browse files
committed
feat(labs): implement Lab 03 Advanced Features compose, tests, and CI
- Replace docker/docker-compose.advanced.yml stub with full implementation - Replace tests/labs/test-lab-*-03.sh stub with full functional test suite - Add lab-03-smoke CI job to .github/workflows/ci.yml New in Lab 03: - zabbix-a03-agent (Agent2) self-monitoring container Resource limits on all containers. Part of Sprint 21 (Lab 03 phase).
1 parent f429a00 commit 4dac085

3 files changed

Lines changed: 349 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,41 @@ run: bash tests/labs/test-lab-19-01.sh
146146

147147
- name: Cleanup
148148
if: always()
149-
run: docker compose -f docker/docker-compose.lan.yml down -v
149+
run: docker compose -f docker/docker-compose.lan.yml down -v
150+
151+
lab-03-smoke:
152+
name: Lab 03 -- Zabbix Advanced Features (Agent2 self-monitoring + extra pollers)
153+
runs-on: ubuntu-latest
154+
needs: validate
155+
continue-on-error: true
156+
steps:
157+
- uses: actions/checkout@v4
158+
159+
- name: Install tools
160+
run: sudo apt-get install -y curl default-mysql-client -qq
161+
162+
- name: Validate advanced compose
163+
run: docker compose -f docker/docker-compose.advanced.yml config -q && echo "Advanced compose valid"
164+
165+
- name: Start advanced stack
166+
run: docker compose -f docker/docker-compose.advanced.yml up -d
167+
168+
- name: Wait for MySQL
169+
run: timeout 120 bash -c 'until docker exec zabbix-a03-db mysqladmin ping -h localhost -uzabbix -pZabbixLab03! --silent; do sleep 5; done'
170+
171+
- name: Wait for Mailhog
172+
run: timeout 60 bash -c 'until curl -sf http://localhost:8723/api/v2/messages; do sleep 5; done'
173+
174+
- name: Wait for Zabbix Web
175+
run: timeout 360 bash -c 'until curl -o /dev/null -sw "%{http_code}" http://localhost:8423/ | grep -q "^[234]"; do sleep 15; done'
176+
177+
- name: Run Lab 19-03 test script
178+
run: bash tests/labs/test-lab-19-03.sh --no-cleanup
179+
180+
- name: Collect logs on failure
181+
if: failure()
182+
run: docker compose -f docker/docker-compose.advanced.yml logs
183+
184+
- name: Cleanup
185+
if: always()
186+
run: docker compose -f docker/docker-compose.advanced.yml down -v

docker/docker-compose.advanced.yml

Lines changed: 142 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,159 @@
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
25
---
6+
name: it-stack-zabbix-lab03
7+
38
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
744
restart: unless-stopped
845
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}
1057
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"
1372
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"
16141
deploy:
17142
resources:
18143
limits:
19-
cpus: "2.0"
20-
memory: G
144+
cpus: "0.25"
145+
memory: 128M
21146
logging:
22147
driver: json-file
23-
options:
24-
max-size: "100m"
25-
max-file: "5"
148+
options: {max-size: "20m", max-file: "3"}
26149
networks:
27-
- it-stack-net
150+
- zabbix-a03-net
28151

29152
networks:
30-
it-stack-net:
153+
zabbix-a03-net:
31154
driver: bridge
32155

33156
volumes:
34-
zabbix_data:
157+
zabbix-a03-db-data:
158+
zabbix-a03-alertscripts:
159+
zabbix-a03-externalscripts:

0 commit comments

Comments
 (0)