Skip to main content

๐Ÿง Linux Agent Setup

Step-by-step guide to install the Monitron Server Agent on a Linux server.


๐Ÿ“‹ Prerequisitesโ€‹

  • Any Linux distribution (Ubuntu, Debian, CentOS, etc.)
  • curl installed (almost always pre-installed)
  • bc installed (for math calculations)
  • Outbound HTTPS access to your Monitron instance

๐Ÿ“ฅ Step 1: Download the Agentโ€‹

# Create a directory for the agent
sudo mkdir -p /opt/monitron

# Copy the agent script (from your Monitron installation's agent/ folder)
sudo cp /path/to/monitron/agent/monitron-agent.sh /opt/monitron/

# Make it executable
sudo chmod +x /opt/monitron/monitron-agent.sh

Or download directly:

sudo curl -o /opt/monitron/monitron-agent.sh https://your-monitron.com/agent/monitron-agent.sh
sudo chmod +x /opt/monitron/monitron-agent.sh

โš™๏ธ Step 2: Configureโ€‹

Edit the script to set your Monitron URL and Agent Key:

sudo nano /opt/monitron/monitron-agent.sh

Change these two lines at the top:

MONITRON_URL="https://your-monitron-instance.com"
MONITRON_KEY="your-agent-key-here"

Using Environment Variables (Alternative)โ€‹

Instead of editing the script, you can set environment variables:

export MONITRON_URL="https://your-monitron-instance.com"
export MONITRON_KEY="your-agent-key-here"

โฐ Step 3: Set Up Cronโ€‹

Add a cron entry to run the agent every minute:

sudo crontab -e

Add this line:

* * * * * /opt/monitron/monitron-agent.sh

โœ… Step 4: Verifyโ€‹

Run it manually first:โ€‹

/opt/monitron/monitron-agent.sh

If it works, you should see the server appear in your Monitron dashboard within a minute.

Check cron is working:โ€‹

# Wait a minute, then check the Monitron dashboard
# Or check the system log:
grep monitron /var/log/syslog

๐Ÿ”ง Troubleshootingโ€‹

Agent not reportingโ€‹

# Test the script manually
bash -x /opt/monitron/monitron-agent.sh

The -x flag shows each command as it runs, helping you identify issues.

"bc: command not found"โ€‹

# Ubuntu/Debian
sudo apt install bc

# CentOS/RHEL
sudo yum install bc

curl SSL errorsโ€‹

# If your Monitron instance uses a self-signed certificate
# Add -k flag to curl in the script (not recommended for production)

Permission deniedโ€‹

sudo chmod +x /opt/monitron/monitron-agent.sh

๐Ÿ“Š What Data Looks Likeโ€‹

Here's a sample of what the agent sends:

{
"agent_key": "your-agent-key",
"cpu_usage": 23.5,
"cpu_iowait": 1.2,
"memory_usage": 67.4,
"memory_total_mb": 8192,
"swap_usage": 0,
"disk_usage": [
{"mount": "/", "usage": 45, "size": "50G", "used": "22G", "avail": "28G"},
{"mount": "/home", "usage": 30, "size": "100G", "used": "30G", "avail": "70G"}
],
"network_rx_bytes": 1234567890,
"network_tx_bytes": 987654321,
"load_1m": 0.5,
"load_5m": 0.3,
"load_15m": 0.2,
"os": "Ubuntu 24.04 LTS",
"hostname": "web-server-1",
"kernel": "6.5.0-44-generic"
}