> For the complete documentation index, see [llms.txt](https://docs.thousandeyes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thousandeyes.com/product-documentation/connected-devices/device-agents/validation-and-troubleshooting/logs-and-service-management.md).

# Logs and Service Management

Use this article to start, stop, and supervise the agent and find its logs. It also explains the agent lifecycle in containerized deployments.

## Service Management

{% tabs %}
{% tab title="Agent Updater" %}
The Agent Updater (`router_agent_updater`) launches and supervises the agent. Start the Updater through your platform's service manager and run only one Updater instance.

```bash
exec /opt/thousandeyes/cdev/router_agent_updater/bin/router_agent_updater
```

{% endtab %}

{% tab title="Agent-only" %}
For agent-only deployments, your process manager starts and supervises the agent directly. Your release process distributes every agent update.

```bash
cd /opt/samknows/router_agent
exec bin/skagent
```

Run only one agent instance.

The signed OpenWrt agent-only IPK package supplies `/usr/libexec/te-cdev-agent/start` as its checked startup entry point. Use this helper instead of calling `skagent` directly for this package.
{% endtab %}
{% endtabs %}

Start the selected component only after the device has WAN connectivity, DNS resolution, and outbound HTTPS access.

| Platform / init                              | Starting point                               | Typical commands                                                                                |
| -------------------------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| OpenWrt feed (IPK) (`te-cdev-agent-updater`) | Your own init or container lifecycle         | `/usr/libexec/te-cdev-agent-updater/check-architecture`, then `exec …/bin/router_agent_updater` |
| OpenWrt feed (IPK) (`te-cdev-agent`)         | Your own init or container lifecycle         | `/usr/libexec/te-cdev-agent/start`                                                              |
| OpenWrt (TAR)                                | `init_examples/procd/`                       | `/etc/init.d/<svc> start` / `stop` / `restart`                                                  |
| RDK-B                                        | `init_examples/` (procd / systemd / SysV)    | Use the command for the init system in your image.                                              |
| Generic Linux (systemd)                      | `init_examples/systemd/`                     | `systemctl {start\|stop\|restart\|status} <svc>`                                                |
| Generic Linux (SysV)                         | `init_examples/`                             | `service <svc> {start\|stop\|restart}`                                                          |
| Container (prplOS / LXC)                     | Container lifecycle manager, such as prplLCM | Start, stop, or update the container (see below).                                               |

## Lab Diagnostics

Find self-test instructions for the current Updater, earlier Updater versions, and agent-only installations in [Validating with Self-Test Mode](https://docs.thousandeyes.com/product-documentation/connected-devices/device-agents/validation-and-troubleshooting/validate-with-self-test-mode.md).

## Logs

{% tabs %}
{% tab title="Agent Updater" %}

| What                         | Path                                                                    |
| ---------------------------- | ----------------------------------------------------------------------- |
| Updater log                  | `/var/run/opt/thousandeyes/cdev/router_agent_updater/updater_log`       |
| Agent runtime and error logs | `/run/opt/samknows/router_agent/` (`log_errors_<n>` when run with `-D`) |

Use the Updater log to confirm activation and agent installation:

```bash
tail -n 100 -f /var/run/opt/thousandeyes/cdev/router_agent_updater/updater_log
grep -E "Unit ID|Activation response|error|Error|failed|Failed" \
  /var/run/opt/thousandeyes/cdev/router_agent_updater/updater_log
```

The Updater prints the Unit ID when activation succeeds. An HTTP 403 or rejected-secret response indicates a credential or backend-provisioning problem.
{% endtab %}

{% tab title="Agent-only" %}
Agent-only does not produce an Updater log. Read agent output through your process manager and inspect the agent runtime directory:

```bash
ls -la /run/opt/samknows/router_agent/
cat /run/opt/samknows/router_agent/unitid
```

The exact runtime root can be changed by the package or platform integration. Use the configured path when it differs.
{% endtab %}
{% endtabs %}

In containers these paths are inside the container. Bind-mount them to host storage to read them from the host, as described below.

## Retry, Backoff, and Restart Behavior

The agent keeps retrying when it cannot reach the service. Use the logs to identify the first stage that has not completed.

### Updater Startup Order

For an Updater installation, each step blocks the steps below it. The first incomplete step identifies where startup is stalled:

| Step                                           | Owner   | What it blocks                                             |
| ---------------------------------------------- | ------- | ---------------------------------------------------------- |
| Activation, which issues the Unit ID           | Updater | Everything                                                 |
| Agent download, verification, and install      | Updater | The agent starting on the device                           |
| Bootstrap, which fetches the backend endpoints | Agent   | The agent accepting local commands, including `skagent -o` |
| Schedule retrieval                             | Agent   | Tests running                                              |

Each of these steps requires DNS and outbound HTTPS. On an isolated bench with no route to the internet, the component retries the first step it cannot complete. If bootstrap caching is enabled, a device that has activated before can use a cached response to progress further than a fresh installation.

For agent-only deployments, there is no package download stage or Updater log. Follow activation, bootstrap, and schedule retrieval in the agent runtime output.

### Updater Retry and Backoff

During normal operation, the Updater checks for a new package every 60 minutes. It can also receive forced actions, such as triggered tests. The first check occurs at a random time within the hour.

| Operation        | Wait after a failure                                                                                                   | Gives up                                                                         |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| Bootstrap        | A random time between 1 second and an upper bound starting at 10 seconds, doubling with each failure, capped at 1 hour | No. Retries indefinitely.                                                        |
| Update check     | A random time up to an upper bound starting at 1 second, doubling with each failure, capped at 1 hour                  | No. Retries indefinitely.                                                        |
| Package download | The same backoff as the update check, but limited to 4 attempts by default                                             | Yes. The installed version keeps running, and the next hourly check tries again. |

### Restart Handling

{% tabs %}
{% tab title="Agent Updater" %}
The Updater does not restart itself after a failure. Configure your service manager to restart it. Otherwise, the installed agent can continue measuring but won't receive updates.

The Updater supervises the agent. It logs an unexpected exit and restarts the agent after a delay. Use the log to confirm that recovery completes or to identify repeated failures.

During a planned stop or package update, the Updater stops the agent before it replaces or restarts the agent. When the Updater starts, it also stops any agent already running from the managed installation. This prevents two instances from measuring from the same device.
{% endtab %}

{% tab title="Agent-only" %}
Your process manager owns restart behavior. Configure it to restart the agent after an unexpected exit and to stop it cleanly before replacing the package. The lifecycle must not leave two agent instances running.
{% endtab %}
{% endtabs %}

Running the agent directly with `-D` uses its built-in supervisor. It restarts the child agent after an unexpected exit and writes rotating error logs under the runtime directory.

## Containerized Deployments

For service control and logs, the container lifecycle manager owns the container. The Agent Updater runs inside it and manages the agent package.

The paths above are inside the container. Bind-mount them to host storage to read them from the host.

A container deployment requires host networking, `skagent.cfg`, host identity inputs, and start-after-WAN ordering. See [Docker](https://docs.thousandeyes.com/product-documentation/connected-devices/device-agents/getting-started/docker.md).
