Skip to content

Developers

Agent protocol

How the monitoring agent talks to the panel.

๐Ÿ‘€ Overview

The monitoring agent keeps one outbound WebSocket to the panel. All traffic โ€” metrics, inventory, actions, command output and terminal data โ€” flows over it as JSON text frames. Nothing listens on the monitored server.

This page describes protocol version 1, for people auditing the agent or building integrations. To install the agent, see Fleet monitoring.

๐ŸŽŸ๏ธ Enrollment

  1. An admin generates an install command in the panel. It carries a one-time token (32 random bytes, valid for one hour).
  2. The installer calls POST /api/fleet/agent/enroll with the token, hostname, architecture, mode, version and machine id.
  3. The panel answers with the server id and an agent key of the form oa_<id>_<secret>. The panel stores only a SHA-256 hash of the key.
  4. The key is written to /etc/orchestrator-agent/agent.json, readable only by root (and the orch-agent group in monitor mode).
JSON
{
  "panel": "https://panel.example.com",
  "serverId": 7,
  "agentKey": "oa_7_โ€ฆ",
  "mode": "control",
  "allowTerminal": true,
  "allowCommands": true
}

A missing switch counts as false.

๐Ÿ”Œ Connection

HTTP
GET /api/terminal/fleet/agent HTTP/1.1
Host: panel.example.com
Upgrade: websocket
Authorization: Bearer oa_7_โ€ฆ
X-Agent-Version: 1.0.0+3a1b2c4
Situation Result
Wrong or revoked key HTTP 401 before the upgrade, or close code 4401
A second connection with the same key the older connection is closed with 4409
Connection lost reconnect with exponential back-off from 2 to 60 seconds (ยฑ20% jitter); every 60 seconds after a 401

Keep-alive: the panel sends a WebSocket ping every 25 seconds and an application ping every 30 seconds to measure latency. Either side drops a connection that has been silent for 90 seconds. Frames are limited to 4 MiB.

โœ‰๏ธ Messages

From the panel Purpose
welcome Connection accepted; sends the reporting intervals.
live Someone is watching: report every 2 seconds instead of 15.
ping Latency check.
inventory, processes Request services, containers and updates, or the process list.
action Run a fixed action (service.restart, reboot, packages.update, docker.start โ€ฆ).
exec Run a command (control mode with allowCommands).
logs Read or follow the journal or a file under /var/log.
cancel Cancel a running request.
pty.open, pty.in, pty.resize, pty.close Terminal session (control mode with allowTerminal).
update Install a new agent build.
From the agent Purpose
hello Version, mode and capabilities after connecting.
metrics A metrics sample.
inventory, processes The requested data.
result The final result of a request.
chunk Streaming output of a running request.
pty.data, pty.exit Terminal output and exit.
pong Latency answer.
error A request was refused or failed, for example forbidden: monitor mode or busy.

๐Ÿ“Š What is collected

  • Every 15 seconds (every 2 seconds while watched): CPU total, per core, steal and I/O wait; load 1/5/15; memory and swap; every real filesystem with inodes; disk I/O; network rates and totals per physical interface; uptime; process count; established TCP connections.
  • Every 5 minutes: systemd services and failed units, Docker containers, pending and security updates, reboot required, OS, kernel, hostname and timezone.

The agent reads no application data, no files outside /var/log (and only on request), and sends nothing to anyone but your panel.

๐Ÿ‘ฎ Enforcement on the agent

The agent itself decides what it allows โ€” the panel cannot override it:

Request Monitor mode Control mode
Metrics, inventory, processes, logs, service status โœ“ โœ“
Fixed actions forbidden: monitor mode โœ“
exec forbidden: monitor mode only with allowCommands
pty.open forbidden: monitor mode only with allowTerminal
update forbidden: monitor mode only with allowCommands

Limits: 8 requests and 4 terminals at a time; output is streamed in 64 KiB chunks, up to 32 MiB per request.

๐Ÿ”„ Updates

An update message carries a version, a URL and a SHA-256 checksum. The agent only accepts a URL on the panel's own origin, downloads the file next to itself, checks that it is a Linux executable with the right checksum, replaces itself and exits so systemd starts the new version. It refuses to update while requests are running.