Prometheus exporter for MeshCore repeaters, read over the mesh: a companion (USB, BLE, or a companion identity in openHop over TCP) logs in to each repeater, asks for status and telemetry with direct packets and serves battery, temperature/humidity, noise floor, RSSI/SNR, packet counters, airtime and uptime on :9200/metrics. - meshcore_exporter.py: command line, MC_* environment or a TOML file with a password per repeater; --check reads every repeater once and exits; interval 1 h (min 15 min); a failed repeater is retried once after 3 min; contacts fetched once per round. - dashboards/: the Grafana dashboard, generated from generate.py (datasource, job and the rate window are variables; TX drawn above zero, RX below). - stack/: Docker Compose with Prometheus and Grafana provisioned, for a USB companion, or on the host network for openHop on the same machine. - systemd/: running without Docker. - README.md (Czech) and AGENTS.md for setting it up with an AI agent. - CI: lint and tests, gitleaks; PR check builds the image; single-platform images per architecture behind a Trivy gate (latest-<arch>, and X.Y.Z-<arch> with a release on tag vX.Y.Z); dependencies by Renovate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
3.5 KiB
Markdown
64 lines
3.5 KiB
Markdown
# Instructions for an AI agent setting this up
|
|
|
|
You are helping someone run meshcore-exporter: a program that reads MeshCore
|
|
repeaters **over a shared public radio channel** and shows them in Grafana.
|
|
README.md has the full reference. This file is the procedure and the rules.
|
|
|
|
## Rules (not negotiable)
|
|
|
|
1. **Read only.** The exporter reads; you never configure the repeater or the
|
|
companion radio for the user. Do not send `set repeat`, `set freq`,
|
|
`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
|
|
asks for it and understands it costs shared airtime (point them to
|
|
https://meshcore.repeater.cz/nastaveni/telemetrie/). Never below 900 (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
|
|
issue. When you show the config to the user, mask the password.
|
|
4. **One client per companion radio.** If the radio is used by a phone app,
|
|
Meshy or meshcli, ask the user to disconnect it; do not kill their
|
|
processes without asking.
|
|
5. **The user knows the hardware.** If they say the board is plugged in, it
|
|
is: look (`ls -l /dev/serial/by-id/`) instead of arguing.
|
|
6. Do not install system packages, change groups or open firewall ports
|
|
without telling the user what and why first.
|
|
|
|
## Procedure
|
|
|
|
1. Ask: do they already run Prometheus and Grafana? Yes → README section 2
|
|
("Jen exportér"). No → section 1 (Docker stack). Docker missing → install
|
|
it the distribution's way, with the user's consent.
|
|
Do they run openHop (repeater/observer)? Then no extra board is needed:
|
|
README section 3 (a dedicated companion identity over TCP). Changing their
|
|
openHop config.yaml is a change to their node: show the block, let them
|
|
apply it.
|
|
2. USB companion: `ls -l /dev/serial/by-id/`. Use the by-id path, never
|
|
`/dev/ttyACM0` (it changes after a replug). Its group:
|
|
`stat -c '%G %g' <that path>`.
|
|
3. Ask for the repeater name exactly as it appears in the MeshCore app, and
|
|
its admin or guest password (MeshCore uses only the first 15 characters).
|
|
4. Fill `stack/.env` from `stack/.env.example` (or a `repeaters.toml`).
|
|
On the Czech mesh set `MC_PATH_HASH_BYTES=2`.
|
|
5. **Verify before starting the service:**
|
|
`docker compose run --rm exporter --check` (stack) or
|
|
`meshcore-exporter … --check`. Success = `1/1 repeaters answered` and
|
|
a `meshcore_battery_millivolts` line. On failure use the table
|
|
"Když to nejde" in README.md; do not retry in a tight loop (every try
|
|
is radio traffic) — wait at least a minute between attempts.
|
|
6. Start: `docker compose up -d`, then `docker compose logs exporter` must
|
|
show `OK bat=`. A first read that fails and logs `retrying … in 180 s`
|
|
is normal (a lost reply, or a login refused shortly after `--check`):
|
|
wait for the retry instead of restarting. Grafana: `http://<host>:3000`, user `admin`.
|
|
7. Tell the user what runs where, how to update
|
|
(`docker compose pull && docker compose up -d`) and where the password is
|
|
stored.
|
|
|
|
## Developing
|
|
|
|
`python3 -m pytest`, `ruff check`, `ruff format --check`, `mypy meshcore_exporter.py`.
|
|
The dashboard is generated: edit `dashboards/generate.py`, run it, commit
|
|
both files. `--help` must keep working without the dependencies installed.
|