commit dcbf8114aa65dc36b73e791f24ee0206bb284456 Author: root Date: Fri Jul 18 22:52:31 2025 +0300 Initial diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..826a6c4 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +POSTGRES_VERSION=16.4 +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgrespassword +POSTGRES_DB=zabbix +TZ=Europe/Kyiv diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..173adc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/volumes +.env diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..89d69c6 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f16b0ec --- /dev/null +++ b/docker-compose.yaml @@ -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 diff --git a/makefile b/makefile new file mode 100644 index 0000000..039b16b --- /dev/null +++ b/makefile @@ -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" diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e4036a6 --- /dev/null +++ b/readme.md @@ -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 isn’t just YAML. +It’s a quiet dialogue between a system and the one who built it.