Skip to content

A distributed, cross-platform monitoring system built in Go that enables centralized management and monitoring of multiple agent daemons across Windows, Linux, and macOS environments.

Notifications You must be signed in to change notification settings

The-Promised-Neverland/NebulaLink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Master-Agent Monitoring System

A distributed, cross-platform monitoring system built in Go that enables centralized management and monitoring of multiple agent daemons across Windows, Linux, and macOS environments.

Architecture Overview

image

πŸ—οΈ System Architecture

Master Server

The central control plane responsible for:

  • Real-time Agent Monitoring: Tracks agent health, system metrics, and connection status
  • WebSocket Hub: Maintains persistent bidirectional connections with all agents
  • REST API: Handles callback responses and administrative operations
  • In-Memory State: Maintains current agent status and metrics in memory

Agent Daemons

Lightweight, cross-platform daemons that run persistently on host machines:

  • System Metrics Collection: CPU usage, disk space, memory, network stats, uptime, OS information
  • Heartbeat Mechanism: Sends health signals every 5 minutes to confirm operational status
  • Local Log Files: Maintains rotated logs locally for diagnosing failures and downtime events
  • Bidirectional Communication: Receives commands via WebSocket, responds via REST callbacks
  • Process Persistence: Managed by Kardianos service wrapper to ensure daemon survives system operations

πŸ”„ Communication Flow

1. Agent β†’ Master (WebSocket)

  • Initial connection and registration
  • Periodic heartbeat (every 5 minutes)
  • System metrics streaming
  • Real-time status updates

2. Master β†’ Agent (WebSocket)

  • On-demand status requests (callback triggers)
  • Log file retrieval requests
  • Configuration updates
  • Command execution requests
  • Remote control signals

3. Agent β†’ Master (REST API)

  • Callback responses (when master requests immediate status before next heartbeat)
  • Log file uploads (upon server request)
  • Large payload transfers

πŸš€ Features

Current Implementation

  • βœ… Cross-platform agent support (Windows, Linux, macOS)
  • βœ… WebSocket-based real-time communication
  • βœ… Daemon process management via Kardianos
  • βœ… System metrics collection and reporting
  • βœ… Heartbeat monitoring (5-minute intervals)
  • βœ… Local log rotation on agents
  • βœ… Callback mechanism for on-demand queries
  • βœ… Manual installation and uninstallation
  • βœ… In-memory state management

Roadmap

  • πŸ”² Authentication and authorization layer
  • πŸ”² Remote agent installation/uninstallation
  • πŸ”² Encrypted WebSocket connections (WSS)
  • πŸ”² Agent auto-discovery and registration
  • πŸ”² Alert system for agent failures
  • πŸ”² Dashboard UI for visual monitoring
  • πŸ”² Agent command execution framework
  • πŸ”² Multi-tenancy support
  • πŸ”² Persistent storage layer (database)

πŸ“‹ Prerequisites

  • Go 1.21 or higher
  • Supported OS: Windows, Linux, macOS
  • Network connectivity between agents and master server

πŸ› οΈ Installation

Master Server

# Clone repository
git clone <your-repo>
cd master-agent

# Build master
cd master
go build -o master

# Run master
./master

Agent Daemon

# Build agent
cd agent
go build -o agent

# Install as service (requires root/admin privileges)
sudo ./agent install

# Start service
sudo ./agent start

πŸ”§ Configuration

Master Configuration

# config/master.yaml
server:
  host: "0.0.0.0"
  port: 8080
  ws_path: "/ws"

heartbeat:
  timeout: 600 # seconds (10 minutes)
  cleanup_interval: 300 # seconds

Agent Configuration

# config/agent.yaml
master:
  url: "ws://master-server:8080/ws"
  api_url: "http://master-server:8080/api"

metrics:
  interval: 300 # seconds (5 minutes)
  
logging:
  level: "info"
  rotation_size: 10 # MB
  max_backups: 5

πŸ“Š Callback Mechanism

The callback system enables the master to request immediate agent status outside the regular heartbeat cycle:

  1. Master sends callback request via WebSocket
  2. Agent receives request, gathers current metrics
  3. Agent POSTs response to Master's REST API endpoint
  4. Master processes and updates in-memory state

This allows for:

  • Immediate health checks on-demand
  • Quick response to administrative queries
  • Reduced latency for critical operations

πŸ“ Logging & Diagnostics

Agent-Side Log Management

Each agent maintains its own local log files with automatic rotation:

  • Local Storage: Logs are written to disk on the agent's host machine
  • Log Rotation: Automatic rotation based on file size/age to prevent disk overflow
  • On-Demand Upload: Master server can request log files via WebSocket
  • Transmission: Agent sends requested log files back to master via REST POST

This architecture ensures:

  • βœ… Minimal network overhead (logs only sent when needed)
  • βœ… Local debugging capability even when disconnected
  • βœ… Centralized log analysis when required by admin
  • βœ… Efficient storage management on agent hosts

Log Retrieval Flow

  1. Admin requests logs for specific agent via Master
  2. Master sends log request to agent via WebSocket
  3. Agent reads requested log file from local disk
  4. Agent POSTs log file to Master's REST API endpoint
  5. Master serves logs to admin for analysis

πŸ” Failure Analysis

When an agent experiences downtime or failures:

  • Events are captured in local rotated log files
  • Master detects missing heartbeats and flags the agent
  • Admin can request log files from the agent (if it comes back online)
  • Logs help diagnose root causes: network issues, system crashes, resource exhaustion, etc.
  • For permanent failures, logs remain on agent host for manual retrieval

πŸ“ Manual Uninstallation

Windows

agent.exe stop
agent.exe uninstall

Linux/macOS

sudo ./agent stop
sudo ./agent uninstall

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

[Your License Here]


Note: This is an active development project. Authentication, persistent storage, and remote management features are planned for upcoming releases.

About

A distributed, cross-platform monitoring system built in Go that enables centralized management and monitoring of multiple agent daemons across Windows, Linux, and macOS environments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published