diff --git a/TODO.md b/TODO.md index 511e7913..6366acee 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ # Smart City Digital Twin — TODO List -> Dernière mise à jour : 2026-05-26 +> Dernière mise à jour : 2026-05-26 22:00 ## ✅ Complété | ID | Tâche | @@ -18,6 +18,7 @@ | telegraf-fix | Noms containers corrigés + BunkerM désactivé | | or-pg-fix | Image PostgreSQL changée → timescaledb-ha:pg15 | | grafana-fix | Dashboard "no data" corrigé — datasource + requêtes Flux | +| grafana-v4 | Dashboard v4 poussé avec 14 panels, données confirmées ✅ | ## 🔴 En cours | ID | Tâche | Notes | @@ -31,22 +32,24 @@ | p4-ditto | Ditto.digitribe.fr | MongoDB localhost hardcodé | | p3-kepler | KeplerGL | Image Docker incomplète | -## ⏳ En attente -| ID | Tâche | -|----|-------| -| p1-bunkerm-telegraf | Réactiver BunkerM dans Telegraf (port 1883 ou 1900 ?) | -| p1-contexus-60 | Configurer les 60 devices Contexus | -| p3-analyse | Analyse: GeoMesa + KeplerGL | -| p1-ngsi | NGSI-LD: validation pipeline (basse priorité) | -| p0-chirpstack | ChirpStack: login API gRPC-REST | -| p1-thingsboard | Relayer ThingsBoard (si CPU dispo) | +## ⏳ En attente (par priorité) +| ID | Tâche | Priorité | +|----|-------|----------| +| p1-contexus-60 | Configurer les 60 devices Contexus | Haute | +| p1-bunkerm-telegraf | Réactiver BunkerM dans Telegraf (port 1883 vs 1900) | Moyenne | +| p1-grafana-maps | Ajouter carte Grafana avec points capteurs GPS | Moyenne | +| p1-thingsboard | Relayer ThingsBoard (si CPU dispo) | Moyenne | +| p3-analyse | Analyse: GeoMesa + KeplerGL | Basse | +| p1-ngsi | NGSI-LD: validation pipeline | Basse | +| p0-chirpstack | ChirpStack: login API gRPC-REST | Basse | ## 📝 Notes 2026-05-26 -- **Grafana** : Dashboard smartcity-martinique-complete v3 — données confirmées (PM2.5, temp, traffic, etc.) +- **Grafana** : Dashboard smartcity-martinique-complete v4 — données confirmées ✅ - **Pipeline** : Simulateur → EMQX/Mosquitto → Telegraf → InfluxDB → Grafana ✅ - **InfluxDB** : bucket `smartcity`, measurement `mqtt_consumer`, tag `topic` pour le type - **OpenRemote** : Abandon pour l'instant, l'utilisateur va recloner le répertoire - **Keycloak** : Recréé manuellement (ancien supprimé par docker-compose up échoué) +- **Grafana provisioning** : smart-city-dashboards.json déplacé en .bak pour éviter écrasement ## Credentials - **Contexus**: iotevadmin / Digitribe972 @@ -55,3 +58,4 @@ - **Redis Contexus**: Digitribe972 - **Telegraf InfluxDB**: token=my-super-token, org=digitribe, bucket=smartcity - **Grafana**: admin / Digitribe972 +- **InfluxDB**: admin / Digitribe972 diff --git a/docker-compose.bunkerm.yml b/docker-compose.bunkerm.yml new file mode 100644 index 00000000..5d69222a --- /dev/null +++ b/docker-compose.bunkerm.yml @@ -0,0 +1,35 @@ +# BunkerM MQTT Broker - Smart City Digital Twin +version: '3.8' + +networks: + smartcity-shared: + external: true + traefik-public: + external: true + +volumes: + bunkerm_mosquitto_data: + external: true + +services: + bunkerm: + image: bunkeriot/bunkerm:latest + container_name: bunkerm-bunkerm-1 + restart: unless-stopped + networks: + - smartcity-shared + - traefik-public + ports: + - "1883:1900" + - "2000:2000" + environment: + - MQTT_PORT=1900 + - CONFIG_API_PORT=2000 + volumes: + - bunkerm_mosquitto_data:/var/lib/mosquitto + healthcheck: + test: ["CMD-SHELL", "bash -c 'echo > /dev/tcp/localhost/1900' || exit 1"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 60s diff --git a/docker-compose.yml b/docker-compose.yml index 2dfc3fa3..57604008 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: # MQTT Brokers - ENABLE_EMQX=1 - ENABLE_MOSQUITTO=1 - - ENABLE_BUNKER=0 + - ENABLE_BUNKER=1 - EMQX_HOST=emqx_emqx_1 - EMQX_PORT=1883 - MOSQUITTO_HOST=smart-city-digital-twin-martinique-mosquitto-1 diff --git a/grafana/provisioning/dashboards/smart-city-dashboards.json b/grafana/provisioning/dashboards/smart-city-dashboards.json.bak similarity index 100% rename from grafana/provisioning/dashboards/smart-city-dashboards.json rename to grafana/provisioning/dashboards/smart-city-dashboards.json.bak diff --git a/scripts/bunkerm-init.sh b/scripts/bunkerm-init.sh new file mode 100755 index 00000000..df34f962 --- /dev/null +++ b/scripts/bunkerm-init.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# BunkerM init script - create MQTT user and start services +set -e + +# Create MQTT user if password file is empty or doesn't exist +if [ ! -s /etc/mosquitto/mosquitto_passwd ]; then + echo "Creating bunker MQTT user..." + mosquitto_passwd -b /etc/mosquitto/mosquitto_passwd bunker bunker 2>/dev/null || true + chown root:root /etc/mosquitto/mosquitto_passwd 2>/dev/null || true + chmod 0700 /etc/mosquitto/mosquitto_passwd 2>/dev/null || true +fi + +# Execute the original entrypoint +exec /bin/sh -c '/docker-entrypoint.sh' diff --git a/simulator.py b/simulator.py index 0d4bf43e..8a0840fb 100644 --- a/simulator.py +++ b/simulator.py @@ -646,7 +646,7 @@ def publish_bunkerm(sid: str, sensor: dict, values: dict) -> bool: import base64, http.cookiejar, urllib.request, json from datetime import datetime, timezone - host = "bunkerm_bunkerm_1:2000" + host = "bunkerm-bunkerm-1:2000" login_url = f"http://{host}/login" data_url = f"http://{host}/api/sensors/data" diff --git a/snapshots/2026-05-26/ARCHITECTURE.md b/snapshots/2026-05-26/ARCHITECTURE.md new file mode 100644 index 00000000..40e742f5 --- /dev/null +++ b/snapshots/2026-05-26/ARCHITECTURE.md @@ -0,0 +1,57 @@ +# Snapshot 2026-05-26 — Smart City Digital Twin Martinique + +## État des services + +### Pipeline de données ✅ FONCTIONNEL +``` +Simulateur (60 capteurs) → EMQX + Mosquitto → Telegraf → InfluxDB → Grafana +``` + +### Containers UP +| Container | Status | Notes | +|-----------|--------|-------| +| smart-city-simulator | ✅ Up 2j | 60 capteurs, MQTT OK | +| smart-city-telegraf | ✅ Up | Connecté EMQX + Mosquitto | +| smart-city-influxdb | ✅ Up healthy | Bucket `smartcity` with data | +| smart-city-grafana | ✅ Up | Dashboard v3, datasource corrigé | +| openremote-postgresql | ✅ Up healthy | timescaledb-ha:pg15 | +| openremote-keycloak | ✅ Up | Recréé manuellement | +| openremote-manager | ❌ Crash loop | Flyway corrigé mais PG recréé | +| contexus-app | ⚠️ Unhealthy | Postgres/Redis OK | +| contexus-postgres | ✅ Up healthy | | +| contexus-redis | ✅ Up healthy | | + +### Containers DOWN (intentionnel pour CPU) +- ThingsBoard, Pulsar, Redpanda, FROST, Stellio, Orion-LD + +## Données InfluxDB confirmées +- Bucket: `smartcity` +- Measurement: `mqtt_consumer` +- Tag `topic`: `smartcity/{type}/{id}` (ex: `smartcity/airquality/1`) +- Types: airquality(20), parking(20), traffic(10), weather(10), light(5), noise(5) + +## Grafana Dashboard +- UID: `smartcity-martinique-complete` +- URL: https://grafana.digitribe.fr/d/smartcity-martinique-complete/smart-city-digital-twin-martinique-complet +- Version: 3 (15 panels, requêtes Flux corrigées) +- Datasource: InfluxDB-SmartCity-Correct (uid: dd1bfc24-...) + +## Fichiers modifiés cette session +- `grafana-datasources.yml` +- `grafana-dashboard-smartcity.json` +- `grafana/provisioning/dashboards/smart-city-dashboards.json` +- `grafana/provisioning/datasources/datasources.yml` +- `openremote/docker-compose.yml` (OR_SETUP_TYPE: "default") +- `TODO.md` (home + projet) +- `session_resume_2026-05-26.md` (nouveau) + +## Commit +- `5bbd5a6` — "fix: Grafana dashboard 'no data' — datasource + Flux queries" +- Push Gitea: ❌ (502 Bad Gateway) + +## Prochaines étapes +1. Recloner le répertoire (décision utilisateur) +2. Relancer OpenRemote après reclonage +3. Push Gitea quand le serveur sera accessible +4. Configurer les 60 devices Contexus +5. Activer BunkerM dans Telegraf diff --git a/telegraf.conf b/telegraf.conf index 619dcec0..909ea348 100644 --- a/telegraf.conf +++ b/telegraf.conf @@ -41,23 +41,23 @@ data_format = "json" qos = 0 -# Input: MQTT Consumer - BunkerM (DISABLED - auth fails, simulator not sending here) -# [[inputs.mqtt_consumer]] -# servers = ["tcp://bunkerm-bunkerm-1:1900"] -# topics = [ -# "airquality/#", -# "traffic/#", -# "parking/#", -# "noise/#", -# "weather/#", -# "light/#", -# "sensor/#", -# "smartcity/#" -# ] -# data_format = "json" -# qos = 0 -# username = "bunker" -# password = "bunker" +# Input: MQTT Consumer - BunkerM +[[inputs.mqtt_consumer]] + servers = ["tcp://bunkerm-bunkerm-1:1900"] + topics = [ + "airquality/#", + "traffic/#", + "parking/#", + "noise/#", + "weather/#", + "light/#", + "sensor/#", + "smartcity/#" + ] + data_format = "json" + qos = 0 + username = "bunker" + password = "bunker" # Output: InfluxDB v2 [[outputs.influxdb_v2]]