Agent Setup
Install and configure the ServerBee agent on your monitored servers.
The ServerBee agent is a lightweight Rust binary that runs on each server you want to monitor. It collects system metrics (CPU, memory, disk, network, load, temperature, GPU, disk I/O) and reports them to the central ServerBee server over a persistent WebSocket connection.
What the Agent Does
- Collects system metrics every 3 seconds (configurable), including disk I/O throughput on all platforms
- Reports metrics to the server over WebSocket
- Executes ping probes (ICMP, TCP, HTTP) assigned by the server
- Provides a PTY shell for web terminal access
- Runs remote commands dispatched from the server
- Manages remote file operations (browse, read, write, upload, download) with path sandbox security
- Monitors Docker containers when Docker daemon is available (stats, logs, events, networks, volumes)
- Supports automatic self-upgrade when the server pushes new versions
- Reconnects automatically with exponential backoff if the connection drops
Installation
Pre-built Binary
Download the agent binary for your platform from the releases page:
chmod +x serverbee-agentInstall Script
Use the install script to download the binary and configure a systemd service automatically:
curl -fsSL https://raw.githubusercontent.com/ZingerLittleBee/ServerBee/main/deploy/install.sh | sudo bash -s agentBuild from Source
cargo build --release -p serverbee-agentThe binary is located at target/release/serverbee-agent.
Docker (Not Recommended)
ServerBee Agent is portable software — it's a single binary file that creates no folders or residual files on your system. Uninstall by simply deleting the binary and config file. We recommend binary installation for the best experience.
If you still prefer Docker, the agent needs privileged access to collect host system metrics:
docker run -d \
--name serverbee-agent \
--privileged \
--net=host \
--pid=host \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /etc/serverbee:/etc/serverbee \
--restart unless-stopped \
ghcr.io/zingerlittlebee/serverbee-agent:latestThe /etc/serverbee volume mount is mandatory. Agent writes its registration token to agent.toml after first connection. Without this volume, container recreation causes duplicate server entries.
Limitations of Docker deployment:
- Requires
--privilegedfor full metrics collection - Temperature and GPU monitoring may not work inside containers
- Web terminal accesses the container environment, not the host
Registration Flow
Agents authenticate with the server using a token. There are two ways to obtain a token:
Automatic Registration (Recommended)
- Get the auto-discovery key from the server startup logs
- Configure the agent with the key:
server_url = "http://your-server-ip:9527"
auto_discovery_key = "your-auto-discovery-key"- Start the agent. It will:
- Send a registration request to
POST /api/agent/registerusing the key as a Bearer token - Receive a
server_idandtokenfrom the server - Save the token to the config file automatically
- Connect via WebSocket using the token for all future sessions
- Send a registration request to
Manual Token
If you prefer not to use auto-discovery, you can manually create a server entry in the dashboard and provide the token directly:
server_url = "http://your-server-ip:9527"
token = "the-agent-token-from-dashboard"Configuration
The agent reads configuration from TOML files in the following order:
/etc/serverbee/agent.toml(system-wide, preferred)agent.toml(working directory)- Environment variables with
SERVERBEE_prefix
Here is a complete agent.toml with all available options:
# Required: URL of your ServerBee server
server_url = "http://your-server-ip:9527"
# Authentication token (auto-populated after registration)
token = ""
# Auto-discovery key for automatic registration (used only if token is empty)
auto_discovery_key = ""
[collector]
interval = 3 # Metric collection interval in seconds
enable_gpu = false # Enable NVIDIA GPU monitoring (requires nvidia-smi)
enable_temperature = true # Enable temperature sensor monitoring
[log]
level = "info" # Log level: trace, debug, info, warn, error
file = "" # Log file path (empty = stdout only)Environment Variables
Like the server, all options support SERVERBEE_ prefixed environment variables:
export SERVERBEE_SERVER_URL="http://your-server-ip:9527"
export SERVERBEE_TOKEN="your-agent-token"
export SERVERBEE_COLLECTOR__INTERVAL=5
export SERVERBEE_COLLECTOR__ENABLE_GPU=trueGPU Monitoring
GPU monitoring is disabled by default because it requires nvidia-smi to be available on the system. To enable it:
- Ensure NVIDIA drivers and
nvidia-smiare installed - Set
enable_gpu = truein the agent config
[collector]
enable_gpu = trueWhen enabled, the agent collects per-GPU metrics:
- Device name
- Memory total and used
- GPU utilization percentage
- GPU temperature
These metrics appear in the server dashboard and can be used in alert rules.
Running as a Systemd Service
For production deployments, run the agent as a systemd service so it starts automatically on boot.
Create /etc/systemd/system/serverbee-agent.service:
[Unit]
Description=ServerBee Agent
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/serverbee-agent
Restart=always
RestartSec=5
User=root
WorkingDirectory=/etc/serverbee
# Optional: limit resource usage
MemoryMax=128M
CPUQuota=10%
[Install]
WantedBy=multi-user.targetThen enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable serverbee-agent
sudo systemctl start serverbee-agentCheck the status:
sudo systemctl status serverbee-agent
journalctl -u serverbee-agent -fThe agent needs to run as root to access all system metrics (temperature sensors, process lists, etc.) and to open PTY sessions for the web terminal. If you do not need terminal access, you can run it as a non-root user, though some metrics may be unavailable.
Auto-Update
The server can push upgrade commands to connected agents. When an upgrade is triggered:
- The server sends an
Upgrademessage with a download URL and version - The agent downloads the new binary
- Verifies the SHA-256 checksum (if provided via
x-checksum-sha256header) - Backs up the current binary (
.bakextension) - Replaces itself with the new binary
- Restarts automatically
This process is transparent and requires no manual intervention on the agent side.
Connection Behavior
The agent maintains a persistent WebSocket connection to the server. If the connection drops:
- It reconnects using exponential backoff starting at 1 second
- The maximum backoff interval is 30 seconds
- A random jitter of +/-20% is applied to avoid thundering herd reconnections
- Upon successful reconnection, the backoff resets to 1 second
During the initial connection:
- The server sends a
Welcomemessage with the assignedserver_idandreport_interval - The agent sends its
SystemInfo(CPU name, cores, arch, OS, kernel, memory, disk, IP addresses, virtualization type, agent version) - The server acknowledges with an
Ack - The server syncs any assigned ping tasks
- The agent begins its periodic metric reporting loop
Collected Metrics
| Metric | Type | Description |
|---|---|---|
cpu | float | CPU usage percentage (0-100) |
mem_used | int | Used memory in bytes |
swap_used | int | Used swap in bytes |
disk_used | int | Used disk space in bytes |
net_in_speed | int | Network inbound speed (bytes/sec) |
net_out_speed | int | Network outbound speed (bytes/sec) |
net_in_transfer | int | Cumulative inbound transfer (bytes) |
net_out_transfer | int | Cumulative outbound transfer (bytes) |
load1 / load5 / load15 | float | System load averages |
tcp_conn | int | Active TCP connections |
udp_conn | int | Active UDP connections |
process_count | int | Running process count |
uptime | int | System uptime in seconds |
temperature | float | CPU temperature (optional) |
gpu | object | GPU metrics per device (optional) |