Upgrading the Agent

Keep your StatusRadar monitoring agent up-to-date with the latest features, bug fixes, and security patches.

Quick Update

The simplest way to update your agent:

curl -s https://statusradar.dev/install-agent.sh | sudo bash -s update

The update reads your existing configuration from /opt/statusradar/config.env, so you don't need to pass your token again.

The update script automatically:

  • Stops the running agent
  • Backs up the current version
  • Downloads the latest agent
  • Updates all plugins
  • Restarts the service

Automatic Self-Update

The agent self-updates by default. On each check-in it compares its own version against the latest version reported by the server. When a newer version is available it downloads it, backs up the current script to /opt/statusradar/statusradar-agent.py.backup, atomically replaces /opt/statusradar/statusradar-agent.py, and re-executes itself to load the new version. Your configuration is untouched.

To disable automatic self-update, edit the systemd unit's ExecStart to pass --no-auto-update:

sudo systemctl edit --full statusradar-agent
# Append --no-auto-update to the ExecStart line, then:
sudo systemctl daemon-reload
sudo systemctl restart statusradar-agent

With self-update disabled, use the manual update command below whenever you want to upgrade.

When to Update

Regular Updates

Update your agent:

  • Monthly - For latest features and improvements
  • On security advisories - Critical security patches
  • Before adding new plugins - Ensure plugin compatibility
  • After system upgrades - Verify compatibility with new OS

Check Current Version

# View agent file modification date
ls -lh /opt/statusradar/statusradar-agent.py

# Check agent logs for version info
sudo journalctl -u statusradar-agent -n 20 --no-pager | grep "Agent"

Update Process

Automatic Update (Recommended)

Step 1: Run the update command

curl -s https://statusradar.dev/install-agent.sh | sudo bash -s update

What happens:

  1. Checks if agent is installed at /opt/statusradar
  2. Stops statusradar-agent service
  3. Backs up current agent to /opt/statusradar/statusradar-agent.py.backup
  4. Downloads latest version as /opt/statusradar/statusradar-agent.py.new
  5. Self-replaces /opt/statusradar/statusradar-agent.py with the new file
  6. Downloads latest plugins to /opt/statusradar/plugins/
  7. Restarts the service

Step 2: Verify the update

# Check service is running
sudo systemctl status statusradar-agent

# View recent logs
sudo journalctl -u statusradar-agent -n 50 --no-pager

Expected output:

● statusradar-agent.service - StatusRadar Server Monitoring Agent
   Active: active (running)

Manual Update

For more control over the update process:

# 1. Stop the agent
sudo systemctl stop statusradar-agent

# 2. Backup current agent
sudo cp /opt/statusradar/statusradar-agent.py \
  /opt/statusradar/statusradar-agent.py.backup

# 3. Download latest version
sudo curl -sL https://statusradar.dev/agent/statusradar-agent.py \
  -o /opt/statusradar/statusradar-agent.py

# 4. Make executable
sudo chmod +x /opt/statusradar/statusradar-agent.py

# 5. Update plugins (if using any)
cd /opt/statusradar/plugins
sudo curl -sL https://statusradar.dev/agent/plugins/redis_plugin.py \
  -o redis_plugin.py
# ... repeat for other plugins

# 6. Restart agent
sudo systemctl start statusradar-agent

# 7. Check status
sudo systemctl status statusradar-agent

Updating Plugins

Plugins are automatically updated when you run the update script. To update specific plugins manually:

Update Single Plugin

cd /opt/statusradar/plugins

# Update Redis plugin
sudo curl -sL https://statusradar.dev/agent/plugins/redis_plugin.py \
  -o redis_plugin.py

# Update MySQL plugin
sudo curl -sL https://statusradar.dev/agent/plugins/mysql_plugin.py \
  -o mysql_plugin.py

# Restart agent to load new plugin
sudo systemctl restart statusradar-agent

Update All Plugins

# Re-run the updater with your current PLUGINS list
curl -s https://statusradar.dev/install-agent.sh | sudo PLUGINS='redis,mysql,nginx' bash -s update

The list must match the PLUGINS value in /opt/statusradar/config.env, since the updater downloads exactly the plugins you name here.

Configuration Preservation

Your Configuration is Safe

The update process preserves:

  • /opt/statusradar/config.env - Your API token and plugin settings
  • Plugin configurations
  • Systemd service configuration

The update process replaces:

  • /opt/statusradar/statusradar-agent.py - Main agent script
  • /opt/statusradar/plugins/*.py - Plugin files

Verify Configuration After Update

# Check your config is intact
cat /opt/statusradar/config.env | grep API_TOKEN

# Verify plugins are configured
cat /opt/statusradar/config.env | grep PLUGINS

Rollback

If the update causes issues, you can rollback to the previous version:

# Stop the new version
sudo systemctl stop statusradar-agent

# Restore backup
sudo mv /opt/statusradar/statusradar-agent.py.backup \
  /opt/statusradar/statusradar-agent.py

# Restart service
sudo systemctl start statusradar-agent

# Verify rollback
sudo systemctl status statusradar-agent

Troubleshooting Updates

Update Script Fails

Error: "Agent not installed"

ERROR: Agent not installed. Please run the installer first.

Solution: The agent must be installed before updating:

TOKEN='your-token' bash -c "$(curl -sL https://statusradar.dev/install-agent.sh)"

Agent Won't Start After Update

Check logs for errors:

sudo journalctl -u statusradar-agent -n 100 --no-pager

Common issues:

1. Python dependency issues

# Reinstall the core dependencies
sudo pip3 install psutil requests urllib3

# Or if the agent uses a virtual environment
sudo /opt/statusradar/venv/bin/pip install psutil requests urllib3

2. Configuration file issues

# Check config syntax
cat /opt/statusradar/config.env

3. Permission issues

# Fix permissions
sudo chmod +x /opt/statusradar/statusradar-agent.py
sudo chown -R root:root /opt/statusradar

Update Downloaded But Service Won't Restart

# Check service status
sudo systemctl status statusradar-agent

# Check what's preventing start
sudo journalctl -u statusradar-agent -n 50 --no-pager

# Try manual start
cd /opt/statusradar
sudo python3 statusradar-agent.py --token YOUR_TOKEN --once --debug

Best Practices

1. Test Updates on Non-Production First

If you have multiple servers:

  1. Update one test server first
  2. Monitor for 24 hours
  3. Then update production servers

2. Update During Maintenance Windows

  • Schedule updates during low-traffic periods
  • Have rollback plan ready
  • Monitor logs after update

3. Check Dashboard After Update

After updating, verify on StatusRadar dashboard:

  1. Server shows as "Online"
  2. Metrics are being collected
  3. Plugins are reporting data
  4. No error alerts

4. Keep Backups

The update script creates .backup files automatically. Keep them for 7 days:

# List backups
ls -lh /opt/statusradar/*.backup

# Clean old backups (older than 7 days)
find /opt/statusradar -name "*.backup" -mtime +7 -delete

Automated Updates

Option 1: Cron Job (Use with Caution)

Only recommended for non-critical environments:

# Edit root crontab
sudo crontab -e

# Add weekly update (Sunday 3 AM)
0 3 * * 0 curl -s https://statusradar.dev/install-agent.sh | bash -s update >> /var/log/statusradar-update.log 2>&1

Option 2: Manual Update Schedule

Safer approach: Set calendar reminder to manually update monthly

# Save this as update-agent.sh
#!/bin/bash
curl -s https://statusradar.dev/install-agent.sh | bash -s update

Run manually when convenient:

sudo bash update-agent.sh

Getting Help

If you encounter issues during update:

  1. Check logs: sudo journalctl -u statusradar-agent -n 100
  2. Rollback: Use the .backup file to restore previous version
  3. Manual test: Run agent with --debug flag
  4. Contact support: Email [email protected] with error logs

Include This Information

When requesting support:

# System info
uname -a
cat /etc/os-release

# Agent version (backup file date)
ls -lh /opt/statusradar/statusradar-agent.py*

# Service status
sudo systemctl status statusradar-agent --no-pager

# Recent logs
sudo journalctl -u statusradar-agent -n 100 --no-pager

Next Steps