Go to file
Ilgiz Kalmetyev 9efc234779 Исправил формирование tail_points в src/robot2zabbix_backend/zabbix_floorplan.py: при смене BSSID теперь добавляется граничная точка с теми же координатами, чтобы потребитель мог разрезать след на цветные сегменты. Из-за этого след больше не должен сливаться в один цвет на переходах между точками доступа. 2026-07-20 23:33:53 +05:00
cache Сделал подписи RSSI на canvas с непрозрачной подложкой 2026-07-03 19:41:28 +05:00
client Исправил отрисовку в app.js: клиент больше не соединяет соседние точки хвоста, если между ними есть явный разрыв. 2026-07-20 00:30:20 +05:00
config Add floorplan support to backend 2026-07-19 11:23:20 +05:00
deploy Сервис реализован как Python-проект с entrypoint, MQTT consumer на paho-mqtt, mapping engine, обёрткой над zabbix_sender, тестами и примером systemd unit. Основной runtime собран в service.py, правила и типы разнесены по mapping.py, parser.py, sender.py и config.py. Конфиг в r2z-backend.yaml приведён к согласованным value_path, а пример unit-файла лежит в robot2zabbix-backend.service. 2026-07-02 16:57:54 +05:00
docs Добавил фильтр по SSID для цветовых bucket-метрик scan_results 2026-07-02 22:04:43 +05:00
geo/src Реализована подложка на leaflet 2026-07-18 23:23:54 +05:00
src/robot2zabbix_backend Исправил формирование tail_points в src/robot2zabbix_backend/zabbix_floorplan.py: при смене BSSID теперь добавляется граничная точка с теми же координатами, чтобы потребитель мог разрезать след на цветные сегменты. Из-за этого след больше не должен сливаться в один цвет на переходах между точками доступа. 2026-07-20 23:33:53 +05:00
tests Исправил формирование tail_points в src/robot2zabbix_backend/zabbix_floorplan.py: при смене BSSID теперь добавляется граничная точка с теми же координатами, чтобы потребитель мог разрезать след на цветные сегменты. Из-за этого след больше не должен сливаться в один цвет на переходах между точками доступа. 2026-07-20 23:33:53 +05:00
tools Реализована подложка на leaflet 2026-07-18 23:23:54 +05:00
.gitignore Сервис реализован как Python-проект с entrypoint, MQTT consumer на paho-mqtt, mapping engine, обёрткой над zabbix_sender, тестами и примером systemd unit. Основной runtime собран в service.py, правила и типы разнесены по mapping.py, parser.py, sender.py и config.py. Конфиг в r2z-backend.yaml приведён к согласованным value_path, а пример unit-файла лежит в robot2zabbix-backend.service. 2026-07-02 16:57:54 +05:00
README.md Add floorplan support to backend 2026-07-19 11:23:20 +05:00
pyproject.toml Реализован встроенный navigation API поверх текущего MQTT backend. Добавлены api и каталог объектов в config/r2z-backend.yaml (line 55), новые типы и парсинг конфига в types.py (line 87) и config.py (line 24), in-memory state store в navigation_state.py (line 1) и aiohttp REST/WebSocket сервер в navigation_api.py (line 1). Сервис в service.py (line 1) теперь обновляет object state на валидных MQTT сообщениях, запускает API в том же процессе и рассылает full snapshot при изменениях. 2026-07-03 16:17:24 +05:00

README.md

robot2zabbix-backend

Python service that subscribes to MQTT telemetry topics and forwards mapped metrics to Zabbix through zabbix_sender.

It also exposes a built-in navigation API for the browser client and a Zabbix-backed floorplan endpoint that can be embedded into a Zabbix 7.4 dashboard through a URL or iframe widget.

When the browser client runs on a different machine, set api.host: 0.0.0.0 in the backend config so the REST and WebSocket endpoints are reachable over the network.

Spool

When spool.enabled is set, every incoming MQTT message is persisted as NDJSON for downstream machine processing.

  • Valid messages are appended under spool/valid/YYYY/MM/DD/HH/<event_kind>.ndjson
  • Invalid messages are appended under spool/invalid/YYYY/MM/DD/HH/<bucket>.ndjson

Each valid record contains status, received_at, topic, and event. Invalid records contain status, received_at, topic, raw_payload, and parse_error.

Navigation API

When api.enabled is set, the backend keeps an in-memory object state store keyed by MQTT agent_id and exposes:

  • GET /api/v1/objects
  • GET /api/v1/objects/locations
  • GET /api/v1/floorplan
  • GET /api/v1/objects/{object_id}
  • GET /api/v1/stream/locations

Object metadata (name, object_type) comes from api.objects in the YAML config. Status values are derived from heartbeat freshness and location freshness using offline_timeout_ms and stale_timeout_ms.

The API sends permissive CORS headers so a browser-based client can consume it from a separate static folder.

Zabbix Floorplan

GET /api/v1/floorplan is intended for the warehouse floorplan viewer embedded in Zabbix 7.4. It reads the current robot state and recent coordinate history from Zabbix items through the Zabbix JSON-RPC API and returns one snapshot that already contains:

  • current robot positions
  • derived status
  • current BSSID and RSSI
  • recent tail points for every robot

To enable this mode, configure the zabbix section with:

  • api_url: full JSON-RPC endpoint, for example http://zabbix.example/api_jsonrpc.php
  • api_token: Zabbix API token with read access to hosts, items, and history
  • history_window_sec: how far back to read item history for tails
  • tail_limit: maximum returned tail points per robot

Required item keys per robot host:

  • wifi.location.x
  • wifi.location.y
  • wifi.state.bssid
  • wifi.signal.rssi_dbm

Optional item key:

  • robot.status

If robot.status is absent, the backend derives online / stale / offline from item freshness using api.stale_timeout_ms and api.offline_timeout_ms.

Web Client

A lightweight static navigation client lives in client/:

  • client/index.html
  • client/styles.css
  • client/app.js

It first tries GET /api/v1/floorplan and, when that endpoint is configured, uses Zabbix as the source of truth for robot positions and tails. If the floorplan endpoint is unavailable, the client falls back to the older navigation API and WebSocket stream.

The viewer renders the local warehouse floorplan with robot markers, status colors, BSSID / RSSI labels, and tails with per-segment color changes when the robot switches access points.

Open client/index.html directly in a browser or serve the client/ folder with any static file server. You can override the API base URL with the api query parameter, for example:

client/index.html?api=http://127.0.0.1:8080

For Zabbix 7.4, publish the client/ folder on an HTTP server reachable by the Zabbix frontend and add it to the dashboard with a URL or iframe-style widget. Use the backend base URL in the api query string so the viewer can call /api/v1/floorplan.

Run

python -m robot2zabbix_backend --config config/r2z-backend.yaml

Tests

pytest -q