diff --git a/AGENTS.md b/AGENTS.md index 216ce57..b34edc6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,9 +11,9 @@ README.md has the full reference. This file is the procedure and the rules. `set radio`, `advert`, `reboot`, `erase` or any other CLI command to a node, with meshcli or anything else. A repeater is part of a community network; a wrong setting breaks routing for other people. -2. **Keep the default interval (3600 s).** Shorter only if the user explicitly +2. **Keep the default interval (28800 s, 8 h).** Shorter only if the user explicitly asks for it and understands it costs shared airtime (point them to - https://meshcore.repeater.cz/nastaveni/telemetrie/). Never below 900 (the + https://meshcore.repeater.cz/nastaveni/telemetrie/). Never below 3600 (the program refuses). 3. **Passwords** go into `stack/.env` or `repeaters.toml` only (both are git-ignored), never into a command you print, a commit, a log or an diff --git a/README.md b/README.md index 5df7853..1871f41 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ repeater ))) mesh ((( companion rádio ── USB ── meshcore-exporter ─ ![Dashboard za 7 dní: baterie, teplota, provoz, signál, airtime a duty cycle (vysílání nad nulou, příjem pod ní, okno 3 h); 1. 11. nová anténa a filtr](docs/dashboard.png) Companion rádio (libovolná MeshCore deska s companion firmwarem, připojená -k počítači) se jednou za hodinu přihlásí na repeater, vyžádá si stav +k počítači) se jednou za 8 hodin přihlásí na repeater, vyžádá si stav a telemetrii přímými pakety a exportér to vystaví na `:9200/metrics`. *English: a Prometheus exporter that logs in to MeshCore repeaters over the @@ -78,7 +78,7 @@ desku do kontejneru nepředá, tam použijte [2.](#2-jen-exportér). Grafana poběží na `http://:3000` (uživatel `admin`, heslo z `.env`), dashboard **MeshCore — repeater** je domovská stránka. První čísla jsou tam do minuty, grafy rychlostí (duty cycle, trend baterie) se -naplní za pár hodin (počítají se z okna 3 h, proměnná dashboardu **Okno**). +naplní až za den (počítají se z okna 24 h, proměnná dashboardu **Okno**). Data drží Prometheus 400 dní (`PROMETHEUS_RETENTION` v `.env`). Aktualizace: `docker compose pull && docker compose up -d`. Stack jede na @@ -147,7 +147,7 @@ jedna z nich, rádio sdílí s tím, co na openHopu už běží. node_name: "muj-exporter" tcp_port: 5002 bind_address: 127.0.0.1 # companion protokol nemá heslo: jen lokálně - tcp_timeout: 0 # exportér drží spojení i hodinu mezi čteními + tcp_timeout: 0 # exportér drží spojení i hodiny mezi čteními ``` `tcp_timeout: 0` je nutný: výchozích 120 s by spojení mezi dvěma čteními @@ -216,7 +216,7 @@ Přepínač má přednost před proměnnou a ta před souborem. | `--repeaters` | `MC_REPEATERS` | — | `jméno[=pubkey][@cesta]`, víc přes čárku | | `--password` | `MC_PASSWORD` | — | heslo pro `--repeaters` | | `--config` | `MC_CONFIG` | — | TOML s bloky `[[repeater]]` (heslo pro každý zvlášť) | -| `--interval` | `MC_INTERVAL` | 3600 | sekundy mezi čteními, minimum 900 | +| `--interval` | `MC_INTERVAL` | 28800 | sekundy mezi čteními (8 h), minimum 3600 | | `--path-hash-bytes` | `MC_PATH_HASH_BYTES` | neměnit | šířka hashů cesty companionu; CZ mesh: 2 | | `--rf-timeout` | `MC_RF_TIMEOUT` | 30 | čekání na jednu odpověď | | `--listen`, `--port` | `MC_LISTEN`, `MC_METRICS_PORT` | 0.0.0.0, 9200 | kde vystavit metriky | @@ -247,9 +247,9 @@ Všechny mají label `node` (jméno repeateru). Jedno čtení repeateru (status + telemetrie, tam i zpět) zabere na českém nastavení (SF7/62,5 kHz) zhruba 0,8 s kanálu, který sdílí všichni. Výchozí -interval je hodina, tedy necelá sekunda za hodinu na repeater. Kratší interval +interval je 8 hodin, tedy necelá sekunda za 8 hodin na repeater. Kratší interval přidá provoz všem okolo a nic užitečného nepřinese: baterie, teplota ani šum -se za pár minut nezmění. Exportér pod 15 minut nejde. +se za pár minut nezmění. Exportér pod hodinu nejde. Než interval zkrátíte, zamyslete se, jak často ta data opravdu potřebujete. Dobře to rozebírá návod [Telemetrie, senzory, GPS](https://meshcore.repeater.cz/nastaveni/telemetrie/) @@ -265,7 +265,7 @@ na meshcore.repeater.cz. | `login failed` | špatné heslo — **MeshCore bere jen prvních 15 znaků**, delší heslo se tiše usekne —, nebo odpověď nedoletěla | | jednou `login failed` / `no status reply`, pak `retrying … in 180 s` | ztracená odpověď v éteru, nebo repeater krátce po předchozím přihlášení (např. `--check`) nový login zahodil; exportér to sám zkusí znovu za 3 minuty, nic nedělejte | | `no status reply` | spojení jen jedním směrem: zkuste trasu přes jiný repeater (`@cesta`) | -| prázdné nebo zubaté grafy rychlostí | počítají se z okna **Okno** (výchozí 3 h): po startu počkejte pár hodin; při jiném intervalu nastavte okno aspoň na 2–3× interval | +| prázdné nebo zubaté grafy rychlostí | počítají se z okna **Okno** (výchozí 24 h): po startu počkejte den; při jiném intervalu nastavte okno aspoň na 2–3× interval | Podrobný log: `--log-level DEBUG`. diff --git a/dashboards/generate.py b/dashboards/generate.py index def75bf..795f9c1 100644 --- a/dashboards/generate.py +++ b/dashboards/generate.py @@ -164,8 +164,8 @@ panels = [ 0, "time() - meshcore_last_scrape_success_timestamp{SEL}", "s", - steps((None, "green"), (4000, "yellow"), (7500, "red")), - "Kdy naposledy uzel odpověděl. Při výchozím intervalu 1 h je normál do ~3600 s.", + steps((None, "green"), (30000, "yellow"), (58000, "red")), + "Kdy naposledy uzel odpověděl. Při výchozím intervalu 8 h je normál do ~28800 s.", ), stat( 5, "Fronta TX", 16, 0, "meshcore_queue_length{SEL}", "none", steps((None, "green"), (3, "yellow"), (8, "red")) @@ -346,12 +346,14 @@ dashboard = { "name": "window", "label": "Okno", "type": "custom", - "query": "1h,3h,6h,12h", - "current": {"text": "3h", "value": "3h"}, - "options": [{"text": w, "value": w, "selected": w == "3h"} for w in ("1h", "3h", "6h", "12h")], + "query": "1h,3h,6h,12h,24h,48h", + "current": {"text": "24h", "value": "24h"}, + "options": [ + {"text": w, "value": w, "selected": w == "24h"} for w in ("1h", "3h", "6h", "12h", "24h", "48h") + ], "hide": 0, "description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, " - "takže okno má být aspoň 2–3× interval čtení (výchozí 1 h → 3h).", + "takže okno má být aspoň 2–3× interval čtení (výchozí 8 h → 24h).", }, { "name": "node", diff --git a/dashboards/meshcore-repeater.json b/dashboards/meshcore-repeater.json index a674611..f10970d 100644 --- a/dashboards/meshcore-repeater.json +++ b/dashboards/meshcore-repeater.json @@ -41,10 +41,10 @@ "name": "window", "label": "Okno", "type": "custom", - "query": "1h,3h,6h,12h", + "query": "1h,3h,6h,12h,24h,48h", "current": { - "text": "3h", - "value": "3h" + "text": "24h", + "value": "24h" }, "options": [ { @@ -55,7 +55,7 @@ { "text": "3h", "value": "3h", - "selected": true + "selected": false }, { "text": "6h", @@ -66,10 +66,20 @@ "text": "12h", "value": "12h", "selected": false + }, + { + "text": "24h", + "value": "24h", + "selected": true + }, + { + "text": "48h", + "value": "48h", + "selected": false } ], "hide": 0, - "description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, takže okno má být aspoň 2–3× interval čtení (výchozí 1 h → 3h)." + "description": "Okno pro rychlosti a duty cycle. Data se mění jen při čtení repeateru, takže okno má být aspoň 2–3× interval čtení (výchozí 8 h → 24h)." }, { "name": "node", @@ -304,11 +314,11 @@ }, { "color": "yellow", - "value": 4000 + "value": 30000 }, { "color": "red", - "value": 7500 + "value": 58000 } ] } @@ -338,7 +348,7 @@ "refId": "A" } ], - "description": "Kdy naposledy uzel odpověděl. Při výchozím intervalu 1 h je normál do ~3600 s." + "description": "Kdy naposledy uzel odpověděl. Při výchozím intervalu 8 h je normál do ~28800 s." }, { "id": 5, diff --git a/meshcore_exporter.py b/meshcore_exporter.py index 7f34edf..d7f2f4e 100644 --- a/meshcore_exporter.py +++ b/meshcore_exporter.py @@ -7,7 +7,7 @@ on http://:9200/metrics: battery, temperature, noise floor, RSSI/SNR, packet counters, airtime, uptime, TX queue. Every reading costs airtime on a shared channel (~0.8 s per repeater on the -Czech preset), so the interval defaults to an hour and cannot go below 15 minutes. +Czech preset), so the interval defaults to 8 hours and cannot go below an hour. How often do you really need the numbers? See https://meshcore.repeater.cz/nastaveni/telemetrie/ @@ -33,10 +33,10 @@ import time from dataclasses import dataclass from typing import Any -__version__ = "1.0.1" +__version__ = "1.1.0" -MIN_INTERVAL = 900 -DEFAULT_INTERVAL = 3600 +MIN_INTERVAL = 3600 +DEFAULT_INTERVAL = 28800 # A failed repeater is retried once after this, not after the full interval: # a lost reply on air is common, and a repeater also drops a login whose # timestamp is not newer than the last one from the same client (replay diff --git a/repeaters.example.toml b/repeaters.example.toml index 1af60c1..78aabda 100644 --- a/repeaters.example.toml +++ b/repeaters.example.toml @@ -7,7 +7,7 @@ serial = "/dev/serial/by-id/usb-REPLACE_ME-if00" # `ls /dev/serial/by-id/` # ble = "AA:BB:CC:DD:EE:FF" # BLE companion # ble_pin = "123456" -interval = 3600 # seconds between rounds (min 900) +interval = 28800 # seconds between rounds (min 3600) # path_hash_bytes = 2 # Czech mesh: 2 # Default password for the blocks below that have none. Admin or guest: diff --git a/stack/.env.example b/stack/.env.example index 625bab8..fe44666 100644 --- a/stack/.env.example +++ b/stack/.env.example @@ -23,10 +23,10 @@ MC_VERSION=latest MC_REPEATERS=REPLACE_ME # Admin or guest password of the repeater(s). Guest: all but external sensors. MC_PASSWORD=REPLACE_ME -# Seconds between readings (min 900). Each reading takes ~1 s of a channel -# everyone shares. A battery does not change in minutes: an hour is plenty; +# Seconds between readings (min 3600). Each reading takes ~1 s of a channel +# everyone shares. A battery does not change in minutes: 8 hours is plenty; # https://meshcore.repeater.cz/nastaveni/telemetrie/ -MC_INTERVAL=3600 +MC_INTERVAL=28800 # Czech mesh: 2 (width of route hashes in packets this radio sends) MC_PATH_HASH_BYTES=2 diff --git a/stack/prometheus.yml b/stack/prometheus.yml index ed53023..d562653 100644 --- a/stack/prometheus.yml +++ b/stack/prometheus.yml @@ -1,5 +1,5 @@ global: - # The exporter reads the mesh every 15 min; scraping its page more often + # The exporter reads the mesh every few hours; scraping its page more often # costs nothing on air and just repeats the last values. scrape_interval: 60s diff --git a/tests/test_config.py b/tests/test_config.py index cf98e79..45e13c5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -38,9 +38,9 @@ def test_cli_minimal(monkeypatch): def test_env_twins(monkeypatch): s = settings( - [], monkeypatch, {"MC_TCP": "h:5000", "MC_REPEATERS": "rpt", "MC_INTERVAL": "1800", "MC_PATH_HASH_BYTES": "2"} + [], monkeypatch, {"MC_TCP": "h:5000", "MC_REPEATERS": "rpt", "MC_INTERVAL": "7200", "MC_PATH_HASH_BYTES": "2"} ) - assert s.tcp == "h:5000" and s.interval == 1800 and s.path_hash_bytes == 2 + assert s.tcp == "h:5000" and s.interval == 7200 and s.path_hash_bytes == 2 def test_interval_floor(monkeypatch): @@ -64,16 +64,16 @@ def test_bad_setup(argv, monkeypatch): def test_toml(tmp_path, monkeypatch): f = tmp_path / "r.toml" f.write_text( - 'serial = "/dev/y"\ninterval = 1800\npassword = "common"\n' + 'serial = "/dev/y"\ninterval = 7200\npassword = "common"\n' '[[repeater]]\nname = "one"\n' '[[repeater]]\nname = "two"\npassword = "own"\npath = "5361"\n' ) s = settings(["--config", str(f)], monkeypatch) - assert s.serial == "/dev/y" and s.interval == 1800 + assert s.serial == "/dev/y" and s.interval == 7200 assert [(t.name, t.password, t.path) for t in s.targets] == [("one", "common", ""), ("two", "own", "5361")] # the command line wins over the file - s = settings(["--config", str(f), "--interval", "2400"], monkeypatch) - assert s.interval == 2400 + s = settings(["--config", str(f), "--interval", "10800"], monkeypatch) + assert s.interval == 10800 def test_example_toml_loads(monkeypatch):