diff --git a/CLAUDE.md b/CLAUDE.md index d407c9d..1895f94 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,8 +10,8 @@ Yodmon is a bridge between the **Yodeck** digital signage API and **Zabbix** mon ```bash pip install flask requests apscheduler -python dev_server.py # web UI at http://localhost:8080 -python snmp_test.py # print OID tree to verify SNMP data +python dev_server.py # web UI at http://localhost:8080 +python snmp_test.py # print OID tree to verify SNMP data python snmp_test.py --filter ``` @@ -20,14 +20,14 @@ python snmp_test.py --filter ## Running in Docker ```bash -docker compose up -d # SNMP on :161/udp, web UI on :8080 +docker compose up -d --build # SNMP on :161/udp, web UI on :8088 ``` -Before starting, set `APP_HOST` in `docker-compose.yml` to the host IP reachable by Zabbix, and optionally fill in `ZABBIX_URL` / `ZABBIX_PASSWORD`. +Edit `docker-compose.yml` before first run: set `APP_HOST` to the IP of the Docker host reachable by Zabbix. ## Configuration -All settings come from environment variables (see `app/config.py`). Key ones: +All settings are environment variables (see `app/config.py`). Key ones: | Variable | Default | Purpose | |---|---|---| @@ -36,6 +36,8 @@ All settings come from environment variables (see `app/config.py`). Key ones: | `ENTERPRISE_OID` | `.1.3.6.1.4.1.99999` | Root OID for all player data | | `SNMP_COMMUNITY` | `public` | SNMPv2c community string | | `ZABBIX_URL` | `""` | Leave empty to disable Zabbix auto-sync | +| `ZABBIX_API_TOKEN` | `""` | Preferred auth (Zabbix 5.4+, required for 6.4+) | +| `ZABBIX_USER` / `ZABBIX_PASSWORD` | — | Fallback auth when no API token | | `DB_PATH` | `/data/yodmon.db` | SQLite file path | ## Architecture @@ -61,7 +63,7 @@ Web UI - col 5 `INTEGER` updating (0/1) - col 6 `INTEGER` registered (0/1) -The Yodeck ID is used directly as the SNMP table index, so OIDs are stable and predictable (e.g. `.1.3.6.1.4.1.99999.1.1.3.54239` = online status of player 54239). +The Yodeck ID is used directly as the SNMP table index — OIDs are stable (e.g. `.1.3.6.1.4.1.99999.1.1.3.54239` = online status of player 54239). **Database** — two tables in `yodmon.db`: - `players` — one row per Yodeck player, upserted on each poll @@ -69,4 +71,17 @@ The Yodeck ID is used directly as the SNMP table index, so OIDs are stable and p **Docker entrypoint** (`entrypoint.sh`) templates `/etc/snmp/snmpd.conf` from env vars at startup, then starts `snmpd` in the background before handing off to `python main.py`. -**Zabbix integration** (`app/zabbix.py`) targets Zabbix 6.0+ API (`item type 20` = SNMP agent). Set `ZABBIX_URL` to enable; the sync runs after every successful Yodeck poll. +## Zabbix integration details + +Targets **Zabbix 7.x** (also works with 6.0+). Each player becomes a host: +- **Host name:** `yodeck-` (e.g. `yodeck-54239`) — `#` is not valid in Zabbix 7.x host names +- **Visible name:** `QRS-` (e.g. `QRS-AMS-COF1`) +- **SNMP interface:** `APP_HOST:161`, SNMPv2c, community from `ZABBIX_SNMP_COMMUNITY` +- **Items:** `yodeck.online`, `yodeck.last_seen`, `yodeck.updating`, `yodeck.registered` — SNMP type 20, polled every 1 minute + +**Authentication:** `ZABBIX_API_TOKEN` is sent as `Authorization: Bearer ` HTTP header (Zabbix 6.4+ style). If not set, falls back to `user.login` with `ZABBIX_USER`/`ZABBIX_PASSWORD`. + +**Required Zabbix setup before first run:** +1. Create host group `Yodeck Players` manually in Zabbix +2. Grant the API token's user group **Read-write** permission on that group (Administration → User groups → Permissions) +3. The API token user needs at minimum **Zabbix Admin** role to create hosts and items