DEV Community

Cover image for K2: a lightweight server monitor that ships as one static binary
Rishat
Rishat

Posted on

K2: a lightweight server monitor that ships as one static binary

I have been tinkering with a server monitoring tool called K2 and wanted to share it here. It tracks system metrics, processes, and Docker containers in real time, and the whole thing is a single static Go binary with zero runtime dependencies.

Why another monitoring tool?

Most setups I saw were either heavy (agents, databases, a bunch of moving parts) or locked to a specific vendor. K2 takes the opposite route: install one binary, point a browser at it, done. It is built to run on minimal hardware and to keep working without internet access.

What it does

  • System metrics: CPU, memory, disk, network
  • Per-process metrics, clickable from the PID in the table
  • Container metrics via the Docker API, clickable from the container name
  • History charts per entity with period selection (1h, 6h, 24h, 7d, 1mo)
  • Data retention with automatic purge (default 7 days)

How it is built

The stack is deliberately boring:

  • Go + Echo on the backend
  • htmx + templ + PicoCSS on the frontend, with Chart.js for the graphs
  • SQLite (pure Go driver, no CGO) for storage

There is no Node.js anywhere in the toolchain. The static assets and the database migrations are embedded into the binary with go:embed, and the database file itself is created and migrated on first start. So a deployment is literally one file.

The UI is a set of HTML fragments swapped in via htmx, so there is no SPA build step and no heavy JS bundle. The page updates in place and stays responsive on cheap hardware.

Install

One line for a bare-metal box with systemd:

curl -fsSL https://raw.githubusercontent.com/tashirka1/k2/main/scripts/install.sh | sudo bash
Enter fullscreen mode Exit fullscreen mode

The script downloads the latest release, installs it to /usr/local/bin/k2, generates admin credentials, and sets up the service.

Note: the prebuilt binary is available only for linux-amd64. On other platforms the installer aborts with a warning, so build from source or use Docker instead.

Or with Docker Compose:

cp env-example .env
make up
Enter fullscreen mode Exit fullscreen mode

Security basics

The admin panel has a login form backed by signed session cookies. It locks the account for a minute after three failed attempts, which keeps a basic brute-force attack at bay on an exposed port.

Why it matters for me

The binary is fully static (built with CGO disabled), which means it runs on minimal machines without pulling in anything else. That plus the curl | sudo bash installer makes it close to a set-and-forget tool for a hobby server or a small homelab.

The project is open source (MIT) and the repo has screenshots of the dashboards. If you run a small server and want a monitoring page that does not cost anything to run, give it a look. Feedback is welcome, either here or in the issues.

Project link: https://github.com/tashirka1/k2

Top comments (0)