The monitoring dashboard provides comprehensive real-time visibility into your self-hosted infrastructure, eliminating the need to SSH into your Pi and run htop.
- CPU Usage: Real-time CPU utilization percentage across all cores
- Memory Usage: Current memory consumption with available/total breakdown
- Disk Space: Disk usage with free space remaining
- Docker Stats: Container counts (running/stopped/paused) and image count
- All Containers View: See every container across all apps in one place
- Resource Metrics: CPU, memory, network I/O, and disk I/O per container
- Container State: Visual badges showing running/stopped/paused status
- Restart Tracking: See how many times each container has restarted
- Auto-refreshes every 10 seconds
- Pauses when browser tab is not visible (saves resources)
- Shows "Updated X seconds ago" timestamp
- Search by container name, app name, or container ID
- Filter by status (All, Running, Stopped)
- Results update instantly as you type
Automatic alerts for:
- System CPU > 90% (critical) or > 80% (warning)
- System Memory > 95% (critical) or > 85% (warning)
- Disk Space > 95% (critical) or > 85% (warning)
- Containers using > 90% CPU
- Containers using > 85% memory
- Stopped containers
- Containers with high restart counts (> 5 restarts)
- Restart Container: Restart any running container with confirmation
- Stop Container: Stop any running container with confirmation
- Immediate feedback with success/error notifications
Returns comprehensive system statistics including CPU, memory, disk, Docker daemon info, and all container metrics.
Response:
{
"node_id": "raspberrypi",
"node_name": "raspberrypi",
"cpu": {
"usage_percent": 45.2,
"cores": 4
},
"memory": {
"total_bytes": 8589934592,
"used_bytes": 4294967296,
"free_bytes": 4294967296,
"available_bytes": 5368709120,
"usage_percent": 50.0
},
"disk": {
"total_bytes": 128849018880,
"used_bytes": 51539607552,
"free_bytes": 77309411328,
"usage_percent": 40.0,
"path": "/"
},
"docker": {
"total_containers": 12,
"running": 8,
"stopped": 4,
"paused": 0,
"images": 15,
"version": "24.0.7"
},
"containers": [
{
"id": "abc123...",
"name": "myapp-web-1",
"app_name": "myapp",
"status": "running",
"state": "running",
"cpu_percent": 12.5,
"memory_usage_bytes": 536870912,
"memory_limit_bytes": 2147483648,
"network_rx_bytes": 1048576,
"network_tx_bytes": 524288,
"block_read_bytes": 10485760,
"block_write_bytes": 5242880,
"created_at": "2024-01-15T10:30:00Z",
"restart_count": 0
}
],
"timestamp": "2024-01-15T14:30:00Z"
}Restarts a specific container by ID.
Response:
{
"message": "Container restarted successfully",
"container_id": "abc123..."
}Stops a specific container by ID.
Response:
{
"message": "Container stopped successfully",
"container_id": "abc123..."
}internal/system/stats.go: System metrics collector using gopsutilinternal/http/system.go: HTTP handlers for monitoring endpointsinternal/docker/manager.go: Container control methods (restart/stop)
web/src/features/monitoring/: Main monitoring pageweb/src/features/monitoring/components/: Reusable monitoring componentsSystemOverview.tsx: System-level metrics cardsContainersTable.tsx: Container list with metricsContainerActions.tsx: Quick action buttonsResourceAlerts.tsx: Alert banners
The architecture is designed to support multiple Raspberry Pis in the future:
- All stats report from local node (hostname as node_id)
- Single API endpoint for system stats
- Container actions execute locally
When adding more Pis:
- Add
nodestable to database - Implement agent/heartbeat system for worker nodes
- Add node switcher in UI
- Aggregate stats across all nodes
Migration Path:
node_idandnode_namefields already included in SystemStats- API can be extended to accept
?node=pi-worker-2parameter - Frontend components designed to work with single or multiple nodes
- Access: Navigate to
/monitoringin the web interface - View System Health: Check the overview cards for CPU, memory, disk, and Docker stats
- Monitor Containers: Scroll to see all containers across all apps
- Search: Use the search bar to find specific containers
- Take Action: Click restart/stop buttons on any container
- Check Alerts: Review any alerts at the top of the page
- Stats collection completes in < 500ms on Raspberry Pi 4
- Frontend only polls when tab is visible
- Minimal overhead on system resources
- Container list handles 50+ containers efficiently
github.com/shirou/gopsutil/v3: Cross-platform system stats library- Provides CPU, memory, and disk usage
- Works on Linux, macOS, Windows
- Uses existing React Query for data fetching
- Uses existing UI components (Cards, Badges, Buttons)
- No additional dependencies required
To test the monitoring dashboard:
-
Start the backend server:
make dev-server
-
Start the frontend dev server:
cd web && npm run dev
-
Navigate to
http://localhost:5173/monitoring -
Verify:
- System stats display correctly
- Containers show up with metrics
- Search and filtering work
- Container actions (restart/stop) work with confirmation
- Alerts appear when resource usage is high
- Auto-refresh updates data every 10 seconds
- Ensure Docker is running
- Check that apps have been deployed
- Verify docker-compose.yml files exist in app directories
- Check browser console for API errors
- Verify
/api/system/statsendpoint is accessible - Ensure authentication is working
- Stats collection runs on-demand only when page is open
- Collection pauses when tab is not visible
- Consider increasing refresh interval if needed
- gopsutil may need elevated permissions on some systems
- CPU/memory stats generally work without sudo
- Disk stats may require read permissions on mount points
Potential additions for Phase 2:
- Historical metrics (store last hour/day of data)
- Graphs and charts for CPU/memory over time
- Email/webhook alerts for critical issues
- Container log streaming in monitoring view
- Batch container operations (restart all, stop all)
- Custom alert thresholds in settings
- Export metrics to Prometheus/Grafana