No description
- Go 99.2%
- Nix 0.4%
- Dockerfile 0.3%
- Makefile 0.1%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .github | ||
| docs | ||
| pb | ||
| proto | ||
| .dockerignore | ||
| .envrc | ||
| .gitignore | ||
| agent.go | ||
| agent_test.go | ||
| checks.go | ||
| checks_test.go | ||
| docker-compose.example.yml | ||
| Dockerfile | ||
| flake.lock | ||
| flake.nix | ||
| go.mod | ||
| go.sum | ||
| hostkeys.go | ||
| hostkeys_test.go | ||
| log.go | ||
| log_test.go | ||
| main.go | ||
| main_test.go | ||
| Makefile | ||
| mikrotik.go | ||
| mikrotik_test.go | ||
| ping.go | ||
| ping_test.go | ||
| README.md | ||
| renovate.json | ||
| SECURITY_AUDIT.md | ||
| snmp.go | ||
| snmp_test.go | ||
| ssh.go | ||
| ssh_test.go | ||
| update.go | ||
| update_test.go | ||
| websocket.go | ||
| websocket_test.go | ||
| workerpool.go | ||
| workerpool_test.go | ||
Towerops Agent
A lightweight Rust-based remote polling agent for Towerops SNMP monitoring.
Overview
The Towerops agent enables customers to deploy SNMP polling infrastructure on their internal networks. The agent connects to the Towerops server via WebSocket and executes SNMP queries as directed by the server.
Features
- Local SNMP Polling: Poll devices on your internal network without exposing them to the internet
- SNMP Trap Receiver: Listen for SNMP v1 and v2c traps from network devices
- Secure Communication: All communication with Towerops uses WebSocket over TLS with token authentication
- Real-time Updates: Server pushes configuration changes instantly via persistent WebSocket connection
- Automatic Reconnection: Exponential backoff reconnection on network failures
- Automatic Updates: Checks for new versions hourly and self-updates when available (requires Docker socket access)
- Low Resource Usage: Built in Rust for minimal memory and CPU footprint (< 256 MB RAM typical)
- Docker Ready: Pre-built Docker images for easy deployment
Quick Start
Using Pre-built Image
Pull the latest image from Docker Hub:
docker pull ghcr.io/towerops-app/towerops-agent:latest
Using Docker Compose
- Create a
docker-compose.ymlfile:
version: '3.8'
services:
towerops-agent:
image: ghcr.io/towerops-app/towerops-agent:latest
restart: unless-stopped
environment:
- TOWEROPS_API_URL=https://towerops.net
- TOWEROPS_AGENT_TOKEN=your-agent-token-here
- LOG_LEVEL=info
# Optional: Enable SNMP trap listener
- TRAP_ENABLED=true
- TRAP_PORT=162
ports:
# SNMP trap listener (UDP) - only needed if TRAP_ENABLED=true
- "162:162/udp"
- Start the agent:
docker-compose up -d
Configuration
The agent is configured via environment variables:
| Variable | Description | Default |
|---|---|---|
TOWEROPS_API_URL |
Towerops API endpoint | Required |
TOWEROPS_AGENT_TOKEN |
Agent authentication token | Required |
LOG_LEVEL |
Logging level (error, warn, info, debug) | info |
TRAP_ENABLED |
Enable SNMP trap listener | false |
TRAP_PORT |
UDP port for SNMP traps | 162 |
Obtaining an Agent Token
- Log in to your Towerops account
- Navigate to your organization's Agents page
- Click "Create New Agent"
- Copy the token (it will only be shown once)
Architecture
The agent uses a WebSocket-based architecture for real-time communication:
- WebSocket Client: Maintains a persistent connection to the Towerops server
- SNMP Executor: Executes SNMP queries (GET, WALK) as directed by the server
- Trap Listener: Optional UDP listener for receiving SNMP traps from devices
Communication Flow
- Agent establishes WebSocket connection to
{api_url}/socket/agent/websocket - Agent authenticates by joining PubSub channel with token
- Server pushes SNMP jobs (queries to execute) to agent
- Agent executes queries and sends results back via WebSocket
- Periodic heartbeats maintain connection health
- On disconnect, agent reconnects with exponential backoff (1s to 60s)
SNMP Trap Listener
When enabled (TRAP_ENABLED=true), the agent listens for SNMP traps:
- Supports SNMPv1 and SNMPv2c trap formats
- Logs received traps with source address, enterprise OID, and variable bindings
- Default port 162 (standard SNMP trap port)
Building from Source
Prerequisites
- Rust 1.91 or later
Build
cargo build --release
The binary will be in target/release/towerops-agent.
Docker Build
docker build -t towerops-agent .
Troubleshooting
Agent Not Connecting
- Verify the API URL is correct (accepts http://, https://, ws://, or wss://)
- Check that the agent token is valid and hasn't been revoked
- Ensure network connectivity to the Towerops API
- Check logs for connection errors:
docker logs towerops-agent
No Metrics Appearing
- Check that equipment is assigned to this agent in Towerops
- Verify SNMP credentials are correct in Towerops equipment settings
- Review agent logs for SNMP polling errors
- Ensure the agent is connected (check Towerops UI for agent status)
Traps Not Received
- Ensure
TRAP_ENABLED=trueis set - Verify UDP port 162 is exposed and not blocked by firewall
- Check that devices are configured to send traps to the agent's IP
- Look for trap messages in logs with
LOG_LEVEL=debug
Resource Requirements
- Memory: 64-128 MB typical, 256 MB maximum
- CPU: 0.1-0.5 cores typical
- Network: Minimal (small protobuf messages over WebSocket)
Security
- Agent token should be kept secret (treat like a password)
- All API communication uses TLS with certificate verification
- Agent requires no inbound network connections (except optional trap listener on UDP 162)
- SNMP community strings are only used locally and never logged
License
Copyright 2026 Towerops