Lightweight Resource Monitoring Agent for Dideban
Dideban Agent is a minimal, fast, and secure system monitoring agent written in Go. It is designed to collect host-level resource metrics and send them to the Dideban Core engine.
The agent follows the same philosophy as Dideban:
Low resource usage Β· Predictable behavior Β· Private by default
- π₯οΈ CPU metrics - Usage percentage & load averages (1m, 5m, 15m)
- π§ Memory metrics - Used, total, available memory with usage percentage
- π½ Disk metrics - Used, total disk space with usage percentage
- β±οΈ Performance tracking - Metric collection duration measurement
- π Periodic collection - Configurable interval-based metric gathering
- π€ HTTP delivery - Push-based transmission with retry logic
- π§ Dual mode operation - Development (mock) and production (HTTP) modes
- π¦ Single binary - No external dependencies or runtime requirements
- π Secure authentication - Bearer token-based API authentication
- π‘οΈ Resilient design - Exponential backoff, timeout handling, graceful shutdown
Dideban Agent is intentionally simple and boring:
- No UI
- No embedded database
- No runtime configuration changes
- No external dependencies
This ensures:
- Minimal attack surface
- Predictable performance
- Easy auditing
- Safe execution on production hosts
+-------------------+
| Dideban Agent |
| |
| +-------------+ |
| | Collectors | |
| | CPU / RAM | |
| | Disk | |
| +------+------+ |
| | |
| +------+------+ |
| | Metrics | |
| | Aggregator | |
| +------+------+ |
| | |
| +------+------+ |
| | HTTP | |
| | Sender | |
| +-------------+ |
+-------------------+
|
v
+-------------------+
| Dideban Core API |
+-------------------+
- Linux (amd64 / arm64) or Windows (amd64)
- No root/administrator privileges required
- Go 1.21+ (for building from source)
# Copy and edit config
cp config.example.yaml config.yaml
vim config.yaml
# Run agent
./dideban-agent --config config.yaml# Copy and edit config
copy config.example.yaml config.yaml
notepad config.yaml
# Run agent
dideban-agent.exe --config config.yamlgit clone https://github.com/MrYazdan/dideban-agent
cd dideban-agent
go build -o dideban-agent ./cmd/dideban-agentgit clone https://github.com/MrYazdan/dideban-agent
cd dideban-agent
go build -o dideban-agent.exe ./cmd/dideban-agentThe agent follows this execution pattern:
- Initialization - Load config, setup logging, initialize collectors
- Collection Loop - Gather metrics from CPU, memory, disk collectors
- Transmission - Send metrics via HTTP (prod) or mock (dev) sender
- Sleep - Wait for next collection interval
- Graceful Shutdown - Handle SIGINT/SIGQUIT/SIGTERM signals
The agent uses a YAML configuration file with comprehensive validation and defaults.
# Agent identification and behavior
agent:
id: "vpc-node-01" # Unique identifier (required)
interval: 30s # Collection interval (default: 30s)
# Dideban Core backend
core:
endpoint: "https://dideban.internal/api/metrics" # API endpoint (required)
token: "AGENT_SECRET_TOKEN" # Auth token (required)
# HTTP sender configuration (optional)
sender:
max_retries: 3 # Retry attempts (default: 3)
initial_retry_delay: 1s # Initial backoff (default: 1s)
max_retry_delay: 30s # Max backoff (default: 30s)
request_timeout: 10s # Request timeout (default: 10s)
client_timeout: 30s # Client timeout (default: 30s)
# Logging configuration
log:
level: "info" # debug, info, warn, error (default: info)
pretty: true # Console formatting (default: true)
# Application mode
mode: "production" # development, production (default: development)All configuration can be overridden using environment variables with DIDEBAN_ prefix:
export DIDEBAN_AGENT_ID="my-server"
export DIDEBAN_CORE_ENDPOINT="https://api.dideban.com/metrics"
export DIDEBAN_CORE_TOKEN="your-secret-token"
export DIDEBAN_MODE="production"set DIDEBAN_AGENT_ID=my-server
set DIDEBAN_CORE_ENDPOINT=https://api.dideban.com/metrics
set DIDEBAN_CORE_TOKEN=your-secret-token
set DIDEBAN_MODE=production- agent.id - Must be unique per host (used for metric identification)
- interval - Supports Go duration format:
30s,1m,5m30s - mode -
developmentuses mock sender,productionuses HTTP sender - Config locations:
- Linux/macOS:
~/.dideban/agent/config.yaml - Windows:
%APPDATA%\dideban\agent\config.yaml
- Linux/macOS:
- Environment variables - Override YAML values using dot notation with underscores
The agent collects and transmits metrics in JSON format:
{
"agent_id": "vpc-node-01",
"timestamp_ms": 1734000000000,
"collect_duration_ms": 14,
"cpu": {
"usage_percent": 37.2,
"load_1": 0.64,
"load_5": 0.52,
"load_15": 0.48
},
"memory": {
"used_mb": 2048,
"total_mb": 8192,
"usage_percent": 25,
"available_mb": 6144
},
"disk": {
"used_gb": 120,
"total_gb": 250,
"usage_percent": 48
}
}| Field | Description | Unit |
|---|---|---|
agent_id |
Unique agent identifier | string |
timestamp_ms |
Collection timestamp | milliseconds (Unix) |
collect_duration_ms |
Time taken to collect metrics | milliseconds |
cpu.usage_percent |
Overall CPU utilization | percentage (0-100) |
cpu.load_* |
System load averages | float |
memory.*_mb |
Memory statistics | megabytes |
disk.*_gb |
Disk space statistics | gigabytes |
- Push-only architecture - Agent initiates all connections
- Bearer token authentication - Static token-based API auth
- No inbound ports - Zero attack surface from network
- TLS support - HTTPS endpoints recommended
- Minimal privileges - No root access required
- Connection pooling - Reuses HTTP connections securely
- Use HTTPS endpoints for production deployments
- Rotate tokens regularly (manual process in v0.1)
- Run as non-root user with minimal system permissions
- Monitor agent logs for authentication failures
- Network isolation - Restrict outbound connections to Dideban Core only
- Automatic token rotation with refresh mechanism
- mTLS support for certificate-based authentication
- Encrypted local storage for sensitive configuration
- Agent attestation and integrity verification
-
Install binary:
sudo cp dideban-agent /usr/local/bin/ sudo chmod +x /usr/local/bin/dideban-agent
-
Create configuration directory:
sudo mkdir -p /etc/dideban-agent sudo cp config.example.yaml /etc/dideban-agent/config.yaml
-
Create systemd service:
# /etc/systemd/system/dideban-agent.service [Unit] Description=Dideban Monitoring Agent After=network.target [Service] Type=simple ExecStart=/usr/local/bin/dideban-agent --config /etc/dideban-agent/config.yaml Restart=always RestartSec=10 [Install] WantedBy=multi-user.target
-
Enable and start:
sudo systemctl enable dideban-agent sudo systemctl start dideban-agent
- Install as Windows Service (using NSSM or similar):
# Using NSSM nssm install "Dideban Agent" "C:\Program Files\dideban-agent\dideban-agent.exe" nssm set "Dideban Agent" Arguments "--config C:\Program Files\dideban-agent\config.yaml" nssm start "Dideban Agent"
# Development mode
./dideban-agent --config config.yaml
# Production mode
DIDEBAN_MODE=production ./dideban-agent --config /etc/dideban-agent/config.yaml# Development mode
dideban-agent.exe --config config.yaml
# Production mode
set DIDEBAN_MODE=production
dideban-agent.exe --config config.yamlDocker and container deployment will be available in future versions.
- β Core metrics collection - CPU, Memory, Disk with concurrent gathering
- β HTTP transmission - Production-ready sender with retry logic
- β Development mode - Mock sender for testing and development
- β Configuration system - YAML + environment variable support
- β Structured logging - JSON and pretty console output
- β Graceful shutdown - Signal handling and resource cleanup
- β Performance tracking - Collection duration measurement
- Host metadata - OS version, kernel, uptime, hardware info
- Network metrics - Interface statistics, bandwidth usage
- Process monitoring - Top processes by CPU/memory usage
- Custom metrics - Plugin system for application-specific metrics
- Health checks - Agent self-monitoring and diagnostics
- Security enhancements - Token rotation, mTLS support
- Container support - Docker metrics, Kubernetes integration
- Advanced filtering - Metric sampling and aggregation
- Local buffering - Offline operation and metric queuing
- Configuration hot-reload - Runtime configuration updates
Contributions are welcome, but simplicity is sacred.
Please:
- Avoid unnecessary abstractions
- Keep the agent boring and predictable
MIT License
Dideban (Ψ―ΫΨ―Ψ¨Ψ§Ω) means Watcher / Guardian β The Agent is the eye that observes each machine silently.