Skip to content

masterlog80/test-copilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RK3566 System Monitor

A lightweight, real-time web dashboard for monitoring CPU, Memory, and NPU usage on RK3566-based boards (e.g. Orange Pi CM4).
Metrics are polled at a configurable interval, persisted to a local JSON file, exposed via a Prometheus /metrics endpoint, and displayed in an interactive dark-themed web UI with Chart.js time-series charts.


UI Preview

RK3566 System Monitor UI


Features

  • Real-time dashboard – live CPU, Memory, and NPU gauges with progress bars, auto-refreshed every poll interval
  • Interactive time-series charts – combined and per-metric Chart.js line graphs with pan, scroll-zoom, and time-window presets (15 m / 1 h / 6 h / 24 h / All)
  • NPU support – reads NPU load from the RK3566 sysfs entry (/sys/kernel/debug/rknpu/load); gracefully degrades when unavailable
  • Data persistence – metrics are written to a JSON file and reloaded on restart; no external database required
  • Configurable retention – raw data kept for a configurable window (default 24 h), then automatically downsampled into 1-hour averages; total history pruned after a configurable number of days (default 14)
  • Prometheus endpoint/metrics exposes system_cpu_percent, system_memory_percent, and system_npu_percent gauges for scraping
  • REST API/api/data (full history), /api/current (latest sample), and /api/config (runtime settings)
  • Docker-ready – single-command deployment via Docker Compose

Quick Start

Docker Compose (recommended)

# Clone the repository
git clone https://github.com/masterlog80/test-copilot.git
cd test-copilot

# Build and start
docker compose up -d

# Open the dashboard
open http://localhost:5001

Note: The container runs with privileged: true to access /sys/kernel/debug/rknpu/load for NPU readings.
You can remove that flag on non-RK3566 hardware — CPU and Memory monitoring will still work.

Docker (manual)

docker build -t rk3566-monitor .
docker run -d \
  --name rk3566-monitor \
  --privileged \
  -p 5001:5001 \
  -v monitor-data:/data \
  rk3566-monitor

Local development

# Python 3.12+ required
pip install -r requirements.txt

# Start the development server
DATA_FILE=/tmp/metrics.json python app.py
# → http://localhost:5001

Environment Variables

Variable Default Description
POLL_INTERVAL 10 Seconds between metric samples
STORE_TIMEFRAME_DAYS 14 Days of data to retain before pruning
DOWNSAMPLE_HOURS 24 Hours of raw-resolution data to keep; older data is averaged into 1-h buckets
DATA_FILE /data/metrics.json Path to the persistent JSON metrics file
NPU_LOAD_PATH /sys/kernel/debug/rknpu/load sysfs path for NPU load (RK3566 only)
PORT 5001 HTTP port the server listens on

API Endpoints

Endpoint Method Description
/ GET Web dashboard (HTML)
/api/current GET Latest metric sample as JSON
/api/data GET Full stored history as JSON array
/api/config GET Active runtime configuration
/metrics GET Prometheus text-format metrics

Example: /api/current

{
  "ts": "2025-01-15T12:34:56.789+00:00",
  "cpu": 43.2,
  "mem": 61.8,
  "npu": 28.5,
  "npu_available": true
}

Project Structure

.
├── app.py              # Flask application – polling, persistence, REST API, Prometheus
├── templates/
│   └── index.html      # Dark-themed dashboard (Bootstrap 5 + Chart.js)
├── static/
│   └── favicon.svg     # SVG chip icon
├── requirements.txt    # Python dependencies
├── Dockerfile          # Production image (gunicorn, non-root user)
└── docker-compose.yml  # Compose stack with volume for persistence

Hardware Compatibility

Feature RK3566 / Orange Pi CM4 Other Linux (x86, RPi, …)
CPU monitoring
Memory monitoring
NPU monitoring ❌ (shown as N/A)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors