Skip to content

Deploying Onagre Agent as a Linux Service

Overview

The Onagre Agent can be deployed as a Linux system service, enabling it to run persistently in the background. This method ensures the agent starts automatically at boot and remains active for continuous monitoring.

Downloading the Agent

The Onagre Agent is available for multiple Linux architectures. Use the appropriate command for your system to download and install the agent:

wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-x64 && chmod +x /usr/local/bin/agent
wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-arm && chmod +x /usr/local/bin/agent
wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-arm64 && chmod +x /usr/local/bin/agent

Creating the Systemd Service

To run the Onagre Agent as a persistent service, create a new systemd service file:

nano /etc/systemd/system/onagent.service

Copy the following service definition, replacing with your actual Onagre Agent token:

[Unit]
Description=Onagre Agent
After=network.target

[Service]
LimitNOFILE=65535
Environment=TOKEN=<YOUR_TOKEN>
ExecStart=/usr/local/bin/agent
RestartSec=5
Restart=always
User=root

[Install]
WantedBy=multi-user.target

Applying the Service Configuration

Once the service file is created, reload the systemd daemon to recognize the new service:

systemctl daemon-reload

Enable the service to start automatically at boot:

systemctl enable onagent

Start the Onagre Agent service:

systemctl start onagent

After a few seconds, the agent should be active:

alt

Updating the Onagre Agent

To update the agent, stop the service, download the latest version, and restart it:

systemctl stop onagent
wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-x64 && chmod +x /usr/local/bin/agent
systemctl start onagent && systemctl status onagent
systemctl stop onagent
wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-arm && chmod +x /usr/local/bin/agent
systemctl start onagent && systemctl status onagent
systemctl stop onagent
wget -O /usr/local/bin/agent https://d.onag.re/agent-linux-arm64 && chmod +x /usr/local/bin/agent
systemctl start onagent && systemctl status onagent

Managing the Agent Service

Checking Service Status

To check if the Onagre Agent is running:

systemctl status onagent

Restarting the Agent

To restart the agent manually:

systemctl restart onagent

Stopping and Disabling the Agent

To stop the agent:

systemctl stop onagent
To disable it from starting at boot:
systemctl disable onagent

Summary

Deploying the Onagre Agent as a Linux systemd service ensures continuous monitoring and automatic startup. This method provides stability, persistence, and easy management for monitoring infrastructure resources.