|
| 1 | +# netmon |
| 2 | + |
| 3 | +A lightweight, self-hosted network monitoring dashboard. Tracks latency, jitter, packet loss, DNS resolution times, and bandwidth — displayed in a live web UI with no external services required. |
| 4 | + |
| 5 | + |
| 6 | +[](LICENSE) |
| 7 | +[](https://golang.org) |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- **Live dashboard** — auto-refreshing charts for latency, throughput, packet loss, jitter, and DNS |
| 14 | +- **Network change detection** — automatically detects Wi-Fi/network switches and tags measurements per network; works on macOS, Linux, Windows, Docker, and Raspberry Pi |
| 15 | +- **Self-contained binary** — single executable with embedded UI, no config files needed |
| 16 | +- **Lightweight** — pings every 60s, speed test every 30min (1 MB); negligible network overhead |
| 17 | +- **SQLite storage** — no database server; data persists in a single file |
| 18 | +- **Cross-platform** — runs on Linux (x86, ARM/Pi), macOS, Windows, and Docker |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Quick Start |
| 23 | + |
| 24 | +### Docker (recommended) |
| 25 | + |
| 26 | +```bash |
| 27 | +docker run -d \ |
| 28 | + --name netmon \ |
| 29 | + --network host \ |
| 30 | + -v netmon-data:/data \ |
| 31 | + ghcr.io/decoded-cipher/netmon:latest |
| 32 | +``` |
| 33 | + |
| 34 | +Or with Docker Compose: |
| 35 | + |
| 36 | +```bash |
| 37 | +docker compose up -d |
| 38 | +``` |
| 39 | + |
| 40 | +Then open **http://localhost:8080**. |
| 41 | + |
| 42 | +### Build from source |
| 43 | + |
| 44 | +Requires Go 1.21+ and a C compiler (`gcc`) for the SQLite driver. |
| 45 | + |
| 46 | +```bash |
| 47 | +git clone https://github.com/decoded-cipher/netmon.git |
| 48 | +cd netmon |
| 49 | +make build |
| 50 | +./netmon |
| 51 | +``` |
| 52 | + |
| 53 | +### Makefile targets |
| 54 | + |
| 55 | +``` |
| 56 | +make build # compile binary → ./netmon |
| 57 | +make run # go run ./cmd/netmon (no build step) |
| 58 | +make clean # remove binary and local database |
| 59 | +make vet # run go vet on all packages |
| 60 | +make docker # build Docker image |
| 61 | +make docker-run # build + run Docker container |
| 62 | +``` |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Configuration |
| 67 | + |
| 68 | +All defaults live in `internal/monitor/monitor.go → DefaultConfig()`. There is no config file — rebuild or set env vars (support planned). |
| 69 | + |
| 70 | +| Setting | Default | Description | |
| 71 | +|---------|---------|-------------| |
| 72 | +| Ping targets | `google.com`, `cloudflare.com` | Hosts to measure latency/loss against | |
| 73 | +| DNS targets | `google.com`, `cloudflare.com` | Hosts to measure DNS resolution time | |
| 74 | +| Ping interval | `60s` | How often to run a ping cycle | |
| 75 | +| Speed test interval | `30m` | How often to test download/upload | |
| 76 | +| Speed test size | `1 MB` | Payload size (kept small to avoid hogging the link) | |
| 77 | +| HTTP port | `:8080` | Dashboard address | |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## Architecture |
| 82 | + |
| 83 | +``` |
| 84 | +cmd/netmon/ Entry point — wires packages, starts HTTP server |
| 85 | +internal/ |
| 86 | + monitor/ Ping + speed workers (concurrent, 60s / 30m intervals) |
| 87 | + network/ Cross-platform gateway detection and SSID identification |
| 88 | + server/ HTTP handler, JSON API response types |
| 89 | + store/ SQLite layer — schema, UPSERT patterns, aggregation queries |
| 90 | +web/ |
| 91 | + index.html Single-page dashboard (TailwindCSS + ApexCharts, embedded at build time) |
| 92 | +``` |
| 93 | + |
| 94 | +**Data flow:** |
| 95 | +1. `pingWorker` pings all targets concurrently, resolves DNS, detects network — saves a `Measurement` row every 60s |
| 96 | +2. `speedWorker` downloads/uploads 1 MB to Cloudflare every 30 min — updates latest bandwidth values |
| 97 | +3. Dashboard polls `GET /api/data` every 30s and renders charts client-side |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Platforms |
| 102 | + |
| 103 | +| Platform | Tested | Notes | |
| 104 | +|----------|--------|-------| |
| 105 | +| macOS (Apple Silicon / Intel) | Yes | Native binary | |
| 106 | +| Linux x86-64 | Yes | Includes Docker | |
| 107 | +| Linux ARM (Raspberry Pi) | Yes | Build with `GOARCH=arm64` | |
| 108 | +| Windows | Partial | Ping parsing works; SSID detection via `netsh` | |
| 109 | +| Docker | Yes | See `Dockerfile` and `docker-compose.yml` | |
| 110 | + |
| 111 | +### Raspberry Pi |
| 112 | + |
| 113 | +```bash |
| 114 | +GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc \ |
| 115 | + go build -o netmon ./cmd/netmon |
| 116 | +``` |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Requirements |
| 121 | + |
| 122 | +- **Go 1.21+** for building from source |
| 123 | +- **CGO enabled** (`CGO_ENABLED=1`) — required by the SQLite driver (`go-sqlite3`) |
| 124 | +- A C compiler (`gcc` / `musl-gcc` / `clang`) at build time; not needed at runtime |
| 125 | +- `ping` available in `PATH` at runtime (standard on all platforms) |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## Contributing |
| 130 | + |
| 131 | +See [CONTRIBUTING.md](CONTRIBUTING.md). |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +[MIT](LICENSE) |
0 commit comments