Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LAN Dashboard

A lightweight LAN services and network monitoring dashboard built with Go (backend) and React + TypeScript + Vite (frontend), backed by SQLite for historical data.

Monitor the health of your local services, probe network connectivity across LAN/domestic/international targets, scan LAN devices, and view historical trend charts — all from a single web UI.

Features

  • 🩺 Service Health — HTTP/TCP/UDP probes for configured services with live status
  • 🌐 Network Monitoring — Ping + HTTP probes across LAN, domestic, and international targets
  • 📈 History Charts — Sparkline trend charts for ping/HTTP latency over hours/days
  • 🔍 LAN Device Scanner — ARP-based scanning to discover devices on your subnet
  • 🔬 Diagnose Tool — Multi-step diagnostic checks (DNS, ping, TCP, HTTP) for offline services
  • 🔄 Auto-Refresh — Background probos every 5 minutes with configurable UI auto-refresh

Quick Start

Docker Compose (Recommended)

git clone https://github.com/37acoder/lan-dashboard.git
cd lan-dashboard
docker compose up -d

Then open http://localhost:9090.

Manual Build

Prerequisites: Go 1.22+, Node.js 20+, ping and fping utilities.

# Build frontend
cd web
npm ci
npm run build
cd ..

# Build backend (with embedded frontend)
CGO_ENABLED=0 go build -tags embed -ldflags="-s -w" -o dashboard .

# Run
./dashboard

Development

# Terminal 1: Start Go API server
go run .  # listens on :9090

# Terminal 2: Start Vite dev server
cd web
npm install
echo "VITE_API_BASE=http://localhost:9090" > .env.local
npm run dev  # listens on :5173 with hot reload

Configuration

Environment Variables

Variable Default Description
PORT 9090 HTTP listen port
SUBNET 192.168.1.0/24 LAN subnet for device scanning
DB_PATH /data/network.db SQLite database path for history
SERVICES_JSON (demo defaults) JSON config for services and network targets

SERVICES_JSON Format

{
  "services": [
    {"id": "myapp", "host": "192.168.1.100", "port": 3000, "check": "/"}
  ],
  "lan": [
    {"name": "Router", "host": "192.168.1.1", "http": true}
  ],
  "domestic": [
    {"name": "Baidu", "host": "baidu.com", "http": true}
  ],
  "international": [
    {"name": "Google", "host": "google.com", "http": true}
  ]
}
  • check: "/" for HTTP HEAD, "ping" for ICMP ping, "tftp" for TFTP/UDP

Frontend Services Config

The frontend services display is configured in web/src/config/services.ts. Customize it to match your setup. For build-time customization, set the VITE_SERVICES_CONFIG environment variable.

API Endpoints

Endpoint Method Description
/api/health GET Service health status (online/offline, latency)
/api/network GET Network probe results (ping + HTTP)
/api/network/history?hours=168&target=&category= GET Historical network data (sparkline charts)
/api/devices GET LAN device scan results
/api/scan GET Trigger a fresh LAN device scan
/api/diagnose?host=X&port=Y GET Multi-step diagnostic check

Example Responses

GET /api/health

{
  "services": {
    "app1": {"status": "online", "latency": 12},
    "app2": {"status": "offline", "latency": 0, "error": "HTTP error: dial tcp..."}
  },
  "summary": {"online": 1, "offline": 1, "total": 2}
}

GET /api/network

{
  "groups": [
    {
      "name": "局域网 (LAN)",
      "targets": [
        {"name": "Router", "host": "192.168.1.1", "ip": "192.168.1.1", "ping_latency_ms": 2, "packet_loss_pct": 0}
      ]
    }
  ],
  "timestamp": "2025-01-15T10:30:00Z"
}

Architecture

lan-dashboard/
├── main.go                  # Go server entry, API routes, static serving
├── embed.go                 # go:embed directive for embedding frontend build
├── Dockerfile               # Multi-stage build (Node + Go → Alpine)
├── docker-compose.yml       # Single-service deployment
├── internal/
│   ├── config/              # Configuration loading (env vars + defaults)
│   ├── health/              # Service health probes (HTTP, ping, TFTP)
│   ├── network/             # Network probes (ping + HTTP)
│   ├── devices/             # LAN device scanner (ARP)
│   ├── diagnose/            # Multi-step diagnostic checker
│   └── store/               # SQLite-backed history storage
└── web/
    ├── src/
    │   ├── App.tsx          # Main app with tab routing
    │   ├── api.ts           # API client (configurable base URL)
    │   ├── config/          # Frontend services configuration
    │   └── components/      # React components (ServiceTab, NetworkTab, DevicesTab)
    ├── package.json
    └── vite.config.ts

Docker

# Build and run
docker compose up -d

# View logs
docker compose logs -f

# Stop
docker compose down

# Rebuild after changes
docker compose up -d --build

The container runs as a non-root user (dashboard) and stores SQLite data in a Docker volume at /data.

License

MIT

About

LAN Services & Network Monitoring Dashboard (Go + React + SQLite)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages