meshcore-exporter 1.0.0
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>
This commit is contained in:
commit
2a9126e258
30 files changed
+3181
No files matched your search
@@ -0,0 +1,35 @@
|
||||
# Copy to .env (git ignores it) and fill in the REPLACE_ME lines.
|
||||
|
||||
# --- the companion: EITHER a radio on USB (A) OR an openHop companion (B) ----
|
||||
# (A) USB
|
||||
MC_SERIAL=/dev/meshcore
|
||||
# `ls -l /dev/serial/by-id/` -- the long name stays the same after a replug,
|
||||
# /dev/ttyACM0 does not.
|
||||
MC_SERIAL_HOST=/dev/serial/by-id/REPLACE_ME
|
||||
# group of that port on this computer: `stat -c %g /dev/ttyACM0`
|
||||
MC_SERIAL_GID=20
|
||||
# (B) openHop on this machine (README "Bez vyhrazené desky"): delete the three
|
||||
# MC_SERIAL* lines above and uncomment these two
|
||||
# MC_TCP=127.0.0.1:5002
|
||||
# COMPOSE_FILE=docker-compose.yml:docker-compose.host.yml
|
||||
|
||||
# amd64 = PC; arm64 = Raspberry Pi 4/5 with a 64-bit system
|
||||
MC_ARCH=amd64
|
||||
# latest, or a release (e.g. 1.0.0) to stay on it
|
||||
MC_VERSION=latest
|
||||
|
||||
# --- the repeaters ------------------------------------------------------------
|
||||
# Name exactly as the repeater advertises it; several: comma separated.
|
||||
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;
|
||||
# https://meshcore.repeater.cz/nastaveni/telemetrie/
|
||||
MC_INTERVAL=3600
|
||||
# Czech mesh: 2 (width of route hashes in packets this radio sends)
|
||||
MC_PATH_HASH_BYTES=2
|
||||
|
||||
# --- Grafana ------------------------------------------------------------------
|
||||
GRAFANA_PASSWORD=REPLACE_ME
|
||||
GRAFANA_PORT=3000
|
||||
@@ -0,0 +1,38 @@
|
||||
# openHop on this machine: everything on the host network, so the exporter
|
||||
# reaches the openHop companion on 127.0.0.1 -- no Docker-bridge-to-host
|
||||
# traffic, which host firewalls (ufw, the default nftables ruleset) block.
|
||||
#
|
||||
# Enable it with one line in .env:
|
||||
# COMPOSE_FILE=docker-compose.yml:docker-compose.host.yml
|
||||
#
|
||||
# Exporter and Prometheus listen on 127.0.0.1 only; Grafana on GRAFANA_PORT
|
||||
# of every interface, as in the default setup.
|
||||
services:
|
||||
exporter:
|
||||
network_mode: host
|
||||
environment:
|
||||
MC_LISTEN: 127.0.0.1
|
||||
MC_METRICS_PORT: "9200"
|
||||
|
||||
prometheus:
|
||||
network_mode: host
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-400d}
|
||||
- --web.listen-address=127.0.0.1:${PROMETHEUS_PORT:-9090}
|
||||
volumes: !override
|
||||
- ./host-network/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus:/prometheus
|
||||
|
||||
grafana:
|
||||
network_mode: host
|
||||
ports: !reset []
|
||||
environment:
|
||||
GF_SERVER_HTTP_PORT: ${GRAFANA_PORT:-3000}
|
||||
PROMETHEUS_PORT: ${PROMETHEUS_PORT:-9090}
|
||||
volumes: !override
|
||||
- ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
|
||||
- ./host-network/datasource.yml:/etc/grafana/provisioning/datasources/prometheus.yml:ro
|
||||
- ../dashboards:/var/lib/grafana/dashboards:ro
|
||||
- grafana:/var/lib/grafana
|
||||
@@ -0,0 +1,58 @@
|
||||
# Exporter + Prometheus + Grafana with the dashboard ready.
|
||||
#
|
||||
# cp .env.example .env # fill in: port of the radio, repeater, password
|
||||
# docker compose up -d
|
||||
# open http://localhost:3000 (admin / GRAFANA_PASSWORD from .env)
|
||||
#
|
||||
# Already have Prometheus and Grafana? You do not need this file: run only the
|
||||
# exporter (README, section "Jen exportér").
|
||||
|
||||
services:
|
||||
exporter:
|
||||
image: git.rfa.cz/tth-pub/meshcore-exporter:${MC_VERSION:-latest}-${MC_ARCH:-amd64}
|
||||
# build: .. # or build it from this checkout instead
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
# USB companion: MC_SERIAL_HOST in .env is mapped here. Without one
|
||||
# (openHop companion over TCP) /dev/null stands in and nothing uses it.
|
||||
# openHop on this machine: docker-compose.host.yml (see .env.example).
|
||||
devices:
|
||||
- "${MC_SERIAL_HOST:-/dev/null}:/dev/meshcore"
|
||||
# The serial port's group on the host (`stat -c %g /dev/ttyACM0`):
|
||||
# dialout = 20 on Debian/Ubuntu/Raspberry Pi OS, uucp = 986 on Arch.
|
||||
group_add:
|
||||
- "${MC_SERIAL_GID:-20}"
|
||||
# Per-repeater passwords: put them in repeaters.toml (see
|
||||
# repeaters.example.toml), set MC_CONFIG=/config/repeaters.toml in .env
|
||||
# and uncomment the volume:
|
||||
volumes: []
|
||||
# - ./repeaters.toml:/config/repeaters.toml:ro
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-400d}
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus:/prometheus
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:13.3.0@sha256:488984b716c0862639f91a698adbe2862677a5a07bad42da5f03f3030883b205
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${GRAFANA_PORT:-3000}:3000"
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:?set GRAFANA_PASSWORD in .env}
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/meshcore-repeater.json
|
||||
volumes:
|
||||
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ../dashboards:/var/lib/grafana/dashboards:ro
|
||||
- grafana:/var/lib/grafana
|
||||
|
||||
volumes:
|
||||
prometheus:
|
||||
grafana:
|
||||
Whitespace-only changes.
@@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: meshcore
|
||||
type: file
|
||||
disableDeletion: true
|
||||
allowUiUpdates: false
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,8 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
Whitespace-only changes.
@@ -0,0 +1,9 @@
|
||||
# docker-compose.host.yml: Prometheus on the host's loopback
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
access: proxy
|
||||
url: http://127.0.0.1:${PROMETHEUS_PORT}
|
||||
isDefault: true
|
||||
@@ -0,0 +1,8 @@
|
||||
# docker-compose.host.yml: the exporter on the host's loopback
|
||||
global:
|
||||
scrape_interval: 60s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: meshcore_exporter
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:9200"]
|
||||
@@ -0,0 +1,9 @@
|
||||
global:
|
||||
# The exporter reads the mesh every 15 min; scraping its page more often
|
||||
# costs nothing on air and just repeats the last values.
|
||||
scrape_interval: 60s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: meshcore_exporter
|
||||
static_configs:
|
||||
- targets: ["exporter:9200"]
|
||||
Reference in new issue
Block a user