🐧 Linux Agent Setup
Step-by-step guide to install the Monitron Server Agent on a Linux server.
📋 前提条件
- Any Linux distribution (Ubuntu, Debian, CentOS, etc.)
curlinstalled (almost always pre-installed)bcinstalled (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"
}