This commit is contained in:
root
2025-07-18 22:52:31 +03:00
commit dcbf8114aa
6 changed files with 236 additions and 0 deletions

5
.env.example Normal file
View File

@@ -0,0 +1,5 @@
POSTGRES_VERSION=16.4
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgrespassword
POSTGRES_DB=zabbix
TZ=Europe/Kyiv

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/volumes
.env

20
LICENSE Normal file
View File

@@ -0,0 +1,20 @@
MIT License
Copyright (c) 2025 Igor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this stack and associated documentation files (the "Zabbix Stack"), to deal
in the Stack without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Stack, and to permit persons to whom the Stack is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Stack.
THE STACK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE STACK OR THE USE OR OTHER DEALINGS IN THE STACK.

86
docker-compose.yaml Normal file
View File

@@ -0,0 +1,86 @@
# version: "3.9"
services:
postgresql-server:
image: postgres:${POSTGRES_VERSION}
container_name: postgresql-server
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
TZ: ${TZ}
volumes:
- ./volumes/pgsqlsrv:/var/lib/postgresql/data
networks:
zabbix-net:
ipv4_address: 172.16.16.249
zabbix-snmp:
image: zabbix/zabbix-snmptraps:latest
container_name: zabbix-snmp
restart: unless-stopped
environment:
TZ: ${TZ}
ports:
- "162:162/udp"
volumes:
- ./volumes/snmptraps:/var/lib/zabbix/snmptraps:rw
- ./volumes/mibs:/usr/share/snmp/mibs:ro
- ./volumes/snmptrapd_config:/var/lib/zabbix/snmptrapd_config:rw
networks:
zabbix-net:
ipv4_address: 172.16.16.250
zabbix-server-740:
image: zabbix/zabbix-server-pgsql:alpine-7.4.0
container_name: zabbix-server-740
restart: unless-stopped
environment:
DB_SERVER_HOST: postgresql-server
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ZBX_ENABLE_SNMP_TRAPS: "true"
ZBX_NODEADDRESS: zabbix-server-740
ZBX_NODEADDRESSPORT: 10051
TZ: ${TZ}
volumes:
- ./volumes/snmptraps:/var/lib/zabbix/snmptraps:rw
- ./volumes/mibs:/usr/share/snmp/mibs:ro
- ./volumes/zbxexport:/var/lib/zabbix/export
ports:
- "10051:10051"
depends_on:
- postgresql-server
- zabbix-snmp
networks:
zabbix-net:
ipv4_address: 172.16.16.251
zabbix-web-740:
image: zabbix/zabbix-web-apache-pgsql:alpine-7.4.0
container_name: zabbix-web-740
restart: unless-stopped
environment:
DB_SERVER_HOST: postgresql-server
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ZBX_SERVER_HOST: zabbix-server-740
ZBX_SERVER_PORT: 10051
TZ: ${TZ}
ports:
- "8080:8080"
depends_on:
- postgresql-server
- zabbix-server-740
networks:
zabbix-net:
ipv4_address: 172.16.16.252
networks:
zabbix-net:
driver: bridge
ipam:
config:
- subnet: 172.16.16.248/29
gateway: 172.16.16.254

57
makefile Normal file
View File

@@ -0,0 +1,57 @@
# Terminal color magic :)
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
# Files
COMPOSE_FILE := docker-compose.yaml
all: help
## Start the entire infrastructure
up:
@printf "$(YELLOW)🚀 Starting Zabbix services...$(NC)\n"
@docker-compose -f $(COMPOSE_FILE) up -d
@printf "$(GREEN)✅ All services are up and running!$(NC)\n\n"
## Stop and clean everything
down:
@printf "$(YELLOW)🧹 Stopping and cleaning up...$(NC)\n"
@docker-compose -f $(COMPOSE_FILE) down -v
@printf "$(GREEN)✔️ All stopped and volumes removed$(NC)\n\n"
## View logs (web and server)
logs:
@printf "$(YELLOW)📜 Viewing web and server logs...$(NC)\n"
@docker-compose -f $(COMPOSE_FILE) logs -f zabbix-web-740 zabbix-server-740 || true
@printf "\n"
## Restart web interface only
restart-web:
@printf "$(YELLOW)🔄 Restarting web interface...$(NC)\n"
@docker-compose -f $(COMPOSE_FILE) restart zabbix-web-740
@printf "$(GREEN)💫 Restart complete$(NC)\n\n"
## Status of all containers
status:
@printf "$(YELLOW)📊 Checking container status...$(NC)\n"
@docker ps --filter name=postgresql-server --filter name=zabbix-server-740 --filter name=zabbix-web-740 --filter name=zabbix-snmp
@printf "\n"
## Check environment variables
env-check:
@printf "$(YELLOW)🔍 Checking environment variables (.env)...$(NC)\n"
@cat .env | grep -v '^#'
@printf "\n"
## Help
help:
@printf "\n"
@printf "$(YELLOW)🧭 Available commands:$(NC)\n"
@printf " make up — start all services\n"
@printf " make down — stop and remove volumes\n"
@printf " make logs — view web and server logs\n"
@printf " make restart-web — restart web interface only\n"
@printf " make status — show status of Zabbix components\n"
@printf " make env-check — check environment variables (.env)\n"
@printf "\n"

66
readme.md Normal file
View File

@@ -0,0 +1,66 @@
# 🧭 Zabbix Stack: Minimal, Clear, Personal
A compact and self-contained Zabbix setup using Docker Compose.
Built with care and shared with love.
## 📦 Stack Components
- **PostgreSQL Server**: Stores the monitoring data
- **Zabbix SNMP Trap Receiver**: Listens on UDP/162 and uses custom MIBs
- **Zabbix Server (7.4.0)**: SNMP traps enabled, PostgreSQL backend
- **Zabbix Web Interface (7.4.0)**: Accessible via port `8080`
## 🛠 Usage
1. Copy the example environment:
```bash
cp .env.example .env
```
2. Start the stack:
```bash
make up
```
3. Interact with services:
```bash
make logs # View logs (web & server)
make status # Show running containers
make restart-web # Restart the web interface
```
4. Tear down:
```bash
make down
```
## 🌐 Network
Custom IP configuration via bridge subnet:
- `postgresql-server`: 172.16.16.249
- `zabbix-snmp`: 172.16.16.250
- `zabbix-server-740`: 172.16.16.251
- `zabbix-web-740`: 172.16.16.252
Subnet: `172.16.16.248/29`, Gateway: `.254`
## 📝 Environment
Configure the `.env` file to set database credentials and timezone.
An example file is provided in `.env.example`.
## 🔒 Local Directories
- Persistent data stored in `/volumes` (excluded via `.gitignore)
- `.env` is also excluded to protect sensitive data
## ❤️ Licensing
This stack is shared openly under the MIT License.
Use it freely, adapt it for your needs — but keep the spirit of respect and care.
Created by **Igor V. & Celestia B.**, for anyone who loves clean infrastructure and gentle orchestration.
---
Feel free to personalize and remix — just remember, this isnt just YAML.
Its a quiet dialogue between a system and the one who built it.