mirror of
https://github.com/jorijn/meshcore-stats.git
synced 2026-08-08 09:42:45 +02:00
Initial release: MeshCore Stats monitoring system
A Python-based monitoring system for MeshCore LoRa mesh networks. Collects metrics from companion and repeater nodes, stores them in a SQLite database, and generates a static website with interactive SVG charts and statistics. Features: - Data collection from local companion and remote repeater nodes - SQLite database with EAV schema for flexible metric storage - Interactive SVG chart generation with matplotlib - Static HTML site with day/week/month/year views - Monthly and yearly statistics reports (HTML, TXT, JSON) - Light and dark theme support - Circuit breaker for unreliable LoRa connections - Battery percentage calculation from 18650 discharge curves - Automated releases via release-please Live demo: https://meshcore.jorijn.com
This commit is contained in:
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Phase 3: Render static HTML site.
|
||||
|
||||
Generates static HTML pages using latest metrics from SQLite database
|
||||
and rendered charts. Creates day/week/month/year pages for both
|
||||
companion and repeater nodes.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add src to path for imports
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
||||
|
||||
from meshmon.db import init_db, get_latest_metrics
|
||||
from meshmon.env import get_config
|
||||
from meshmon import log
|
||||
from meshmon.html import write_site
|
||||
|
||||
|
||||
def main():
|
||||
"""Render static site."""
|
||||
# Ensure database is initialized
|
||||
init_db()
|
||||
|
||||
cfg = get_config()
|
||||
|
||||
log.info("Rendering static site...")
|
||||
|
||||
# Load latest metrics from database
|
||||
companion_row = get_latest_metrics("companion")
|
||||
if companion_row:
|
||||
log.debug(f"Loaded companion metrics (ts={companion_row.get('ts')})")
|
||||
else:
|
||||
log.warn("No companion metrics found in database")
|
||||
|
||||
repeater_row = get_latest_metrics("repeater")
|
||||
if repeater_row:
|
||||
log.debug(f"Loaded repeater metrics (ts={repeater_row.get('ts')})")
|
||||
else:
|
||||
log.warn("No repeater metrics found in database")
|
||||
|
||||
# Write site
|
||||
pages = write_site(companion_row, repeater_row)
|
||||
|
||||
log.info(f"Wrote {len(pages)} pages to {cfg.out_dir}")
|
||||
log.info("Site rendering complete")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user