Skip to content

About

Lightweight dependency-free server dashboard in PHP and JavaScript for live CPU and RAM monitoring with a Chart.js graph. Non-blocking metric collection on Linux and Windows.

Topics

Resources

Stars

28 stars

Watchers

20 watching

Forks

Repository files navigation

SimpleServerStat

License: MIT PHP CI

A small, dependency-light server dashboard that shows live CPU and RAM telemetry in the browser. The backend is plain PHP; the frontend is one static page with a hand-drawn canvas chart. No framework, no build step.

SimpleServerStat dashboard

Features

  • Live CPU and memory chart with a rolling two-minute window, refreshed every two seconds.
  • Circular gauges, host details and a live API status indicator.
  • Non-blocking metric collection: Linux reads /proc, Windows uses WMI (wmic, with a PowerShell CIM fallback). No slow top, mpstat or iostat sampling.
  • Self-contained frontend: local brand fonts, custom canvas chart, no CDN dependencies at runtime.
  • Optional shared-secret token to gate the JSON API.
  • Responsive layout that works down to small phones.
  • Accessible basics: skip link, focus styles, reduced-motion support, labelled chart and a live status region.

Requirements

  • PHP 7.4+ served by any web server (Apache, Nginx + PHP-FPM, or php -S).
  • Linux for the most precise metrics (reads /proc). On Windows the page and chart work fully via WMI; on other platforms the page loads but live charts may be empty.

Node.js is only needed for the local screenshot tooling and tests. It is not required to run the dashboard.

Project layout

app/
  index.php              Dashboard markup
  loader.php             JSON API (?action=system_info | general)
  config.example.php     Configuration template
  assets/
    app.css              Brand styles for the dashboard
    app.js               Polling, gauges and canvas chart
    fonts/               Manrope / Montserrat, self-hosted
  logo.png, back.webp    Static assets
  robots.txt
tools/
  screenshot.mjs         Records screenshot.jpg with Playwright
tests/
  run-tests.mjs          Local integration tests (not run in CI)
screenshot.jpg

Running

Serve the app/ directory with PHP:

php -S 0.0.0.0:8080 -t app

Then open http://localhost:8080/.

On Windows you can double-click start.bat — it starts the server and opens the browser in one step.

Configuration

Copy the template and edit it (the real file is gitignored):

cp app/config.example.php app/config.php

Set access_token to a non-empty value to require a token on the API. When set, requests must include it via ?token=... or the X-Auth-Token header; the dashboard injects it automatically.

The token is a basic safeguard only. Because index.php exposes the token to the browser, protect the page itself at the web-server level (HTTP basic auth or an IP allowlist) if the data must stay private.

API

Endpoint Description
loader.php?action=system_info { load, memory_usage } (live)
loader.php?action=general { cpu_count, php_ver, os_data, hostname, server_time }

memory_usage contains total, used, free, available, cached (GiB) and usage (integer percent).

Development

# Start the built-in server
php -S 127.0.0.1:8080 -t app

# Windows: one-click launcher
start.bat

# Lint all PHP files
find app -name '*.php' -print0 | xargs -0 -n1 php -l 2>&1 | grep -v '^No syntax'

All PHP files are linted on every push and pull request via GitHub Actions (see .github/workflows/ci.yml).

Screenshot

The README image is generated from the real page with deterministic mocked telemetry:

npm install
npx playwright install chromium   # first time only
npm run screenshot
# or: node tools/screenshot.mjs --out docs/preview.jpg

Tests

Local integration tests start PHP and Chromium, check both API endpoints, the rendered dashboard, the mobile layout, the canvas chart and token auth:

npm install
npm test

The tests/ folder is intentionally not part of CI.

Limitations / Caveats

  • On Linux the first poll after server start returns a load-average approximation; subsequent polls (every 2s) show the true /proc/stat delta.
  • On Windows wmic is preferred; if it is unavailable (Windows 11 24H2 has it as an optional feature) the PowerShell CIM fallback is transparently used.
  • The built-in PHP server is single-threaded. For production with multiple concurrent viewers, serve behind Nginx or Apache.
  • The shared-secret token is a basic safeguard only — because index.php exposes it client-side, protect the whole app/ directory at the web-server level for real privacy.

Credits

  • Manrope and Montserrat — typefaces (SIL Open Font License), self-hosted in app/assets/fonts/.
  • Chart drawn with the Canvas 2D API — no charting library at runtime.

License

Released under the MIT License.

About

Lightweight dependency-free server dashboard in PHP and JavaScript for live CPU and RAM monitoring with a Chart.js graph. Non-blocking metric collection on Linux and Windows.

Topics

Resources

Stars

28 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages