Lightweight, fast system monitoring API written in Go.
Provides CPU, memory, disk, network and load metrics with both raw values and strings, e.g. 1.23 GB
, 12.34%
). Built for Linux (Debian/Ubuntu).
- Background StatsCollector with configurable refresh interval (caches metrics to reduce request latency).
- Endpoints return both raw and readable fields for easy UI/alerts and programmatic use.
/health
endpoint (uptime, version, time).- Logging + panic recovery middleware.
- Simple CORS header (
Access-Control-Allow-Origin: *
). - Graceful shutdown (SIGINT/SIGTERM) and HTTP timeouts.
- Configurable via
config.json
.
git clone https://github.com/mambuzrrr/brejax-system-stats-api.git
cd brejax-system-stats-api
Make sure you have Go installed (go version
should return a valid version).
go mod tidy
Edit the config.json
file to customize your port and endpoint paths:
{
"port": 8123,
"refresh_interval_sec": 5,
"version": "0.1.0",
"endpoints": {
"stats": "/system-stats",
"cpu": "/cpu-info",
"memory": "/memory-info",
"disk": "/disk-info",
"network": "/network-info",
"load": "/load-info",
"health": "/health"
}
}
go run main.go
Endpoint | Description |
---|---|
/system-stats |
Full system stats: CPU, memory, disk, etc. |
/cpu-info |
Current CPU usage percentage. |
/memory-info |
RAM usage (total, used, percentage). |
/disk-info |
Disk usage (total, used, percentage). |
/network-info |
Network I/O statistics. |
/load-info |
System load averages (1, 5, 15 mins). |
/health |
Service health: status , uptime , version , time |
{
"cpu": {
"raw": [1.23],
"readable": ["1.23%"]
},
"memory": {
"total": 33554432000,
"total_readable": "31.25 GB",
"used": 2264924160,
"used_readable": "2.11 GB",
"used_percent": 6.76,
"used_percent_readable": "6.76%"
},
"disk": {
"total": 500107862016,
"total_readable": "465.66 GB",
"used": 200123435008,
"used_readable": "186.38 GB",
"used_percent": 40.02,
"used_percent_readable": "40.02%"
},
"network": [
{
"name": "eth0",
"bytes_sent": 123456789,
"bytes_sent_readable": "117.74 MB",
"bytes_recv": 987654321,
"bytes_recv_readable": "941.90 MB"
}
],
"system_load": {
"raw": {"load1": 0.12, "load5": 0.15, "load15": 0.18},
"readable": {"load1": "0.12", "load5": "0.15", "load15": "0.18"}
},
"updated_at": "2025-09-12T13:13:34Z"
}