> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/sonar/deploy-operate/agent-updates.md).

# Update agents

How SONAR agents update themselves every hour, the setting that controls it, what a device does during an update, and how to check the version per device.

## What this is and when to use it

When SONAR moves to a new agent version, the agents already installed update themselves: you do not reinstall them. This page explains how that update reaches each device, what the device does while it updates, how to follow the updates in the console, and how to check which version a device runs.

## Before you start

* To see the automatic update setting, your role has **View Core Settings** in **Admin Center › Roles**.
* To follow updates in **Agents › Pending Actions**, it has **List Pending Actions**.
* The devices must be able to download from the SONAR API address on 443/tcp, through the proxy configured at install time if there is one. See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md).

## How updates reach devices

1. **Automatic self update** is controlled by **Enable agent automatic self update** in **Admin Center › Settings**, tab **General** (tooltip *Runs at 35mins past every hour*). The console shows the option read-only; it is turned on or off with DataDike implementation support.
2. While it is on, at 35 minutes past every hour SONAR looks for agents running a version older than the current agent version and sends each of them an update command over its connection.
3. For each of those devices, a pending action **Agent update to \<version>** is recorded. **Due** shows the time of the next update cycle.
4. The device downloads the new agent from the API address and installs it (see below). Its service restarts on the new version.
5. Once the device is back **Online** and reporting the new version, SONAR marks the pending action completed, within a couple of minutes.

A device that is switched off or disconnected at 35 minutes past the hour does not receive the command. The next hourly cycle sends it again, so the device updates in the first cycle after it reconnects. There is nothing to schedule per device.

## What the device does during an update

| Platform | Steps                                                                                                                                                                                                                           |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Windows  | Waits a random 1 to 15 seconds, downloads the update installer to `C:\ProgramData\Sonar\`, and runs it silently. The installer stops the `sonarrmm` service, replaces `sonarrmm.exe`, registers the service again and starts it |
| Linux    | Downloads the new agent next to `/usr/local/bin/sonaragent`, replaces the file, restores its SELinux context where SELinux is enforcing, and restarts `sonaragent.service`                                                      |
| macOS    | Downloads the new agent next to `/opt/sonaragent/sonaragent`, replaces the file, and restarts the `sonaragent` launch daemon                                                                                                    |

What stays as it is:

* the agent configuration — client, site, type and the optional features chosen at installation;
* the remote access agent;
* on Windows, the productivity module (`SonarProductivityService`).

The device is unreachable from the console only for the seconds the service takes to restart.

## What you should see

* In **Agents › Pending Actions** (**All Pending Actions**), rows with the update icon, **Description** *Agent update to \<version>*, and the **Agent**, **Client** and **Site** of each device waiting for the update. They leave the list as devices complete the update; **Show N Completed** brings them back.
* In **Dashboard › Sysadmin**, the **Pending Actions** column counts the pending actions of each device, including the update.
* On a device, **Pending Agent Actions** in the device action menu opens **Pending Actions for \<hostname>** with the same information for that device alone.

## How to verify it worked

1. In **Dashboard › Sysadmin**, select the device. The details panel header shows the agent version next to the host name.
2. In **Agents › Pending Actions**, the device no longer has a pending **Agent update** row. With **Show N Completed**, its update appears as **Completed**.
3. On the device itself:
   * **Windows:** run `"C:\Program Files\Sonar\sonarrmm.exe" -version`; the first line reads *Sonar RMM Agent: \<version>*. Running `"C:\Program Files\Sonar\sonarrmm.exe"` without arguments shows the version in the title of the **Sonar RMM** status box.
   * **Linux:** `/usr/local/bin/sonaragent -version`.
   * **macOS:** `/opt/sonaragent/sonaragent -version`.

## Common errors

| Symptom                                                                       | Cause                                                          | Fix                                                                                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The **Agent update** pending action stays for a device across several cycles  | The device is offline, or cannot download from the API address | Check **Agent Status** and **Last Response**. If the device is online, check that it can reach the API address on 443/tcp, then look for download errors in the agent log. See [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md#agent-logs) |
| A Windows device stops reporting after an update cycle                        | The `sonarrmm` service is not running on the device            | On the device, start the `sonarrmm` service; if it is missing, reinstall the agent. See [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md)                                                                                                   |
| No **Agent update** rows appear although devices run an older version         | **Enable agent automatic self update** is off for the instance | Contact DataDike implementation support                                                                                                                                                                                                                                            |
| An installer saved before the new version stops with *Old installer detected* | Installers carry the agent version they were generated with    | Generate a new installer. Agents already installed are not affected; they update themselves                                                                                                                                                                                        |

## Related pages

* [Troubleshoot agents](https://wiki.datadike.com/sonar/deploy-operate/troubleshooting.md)
* [Deploy agents at scale](https://wiki.datadike.com/sonar/deploy-operate/mass-deployment.md)
* [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md)
* [General settings](https://wiki.datadike.com/sonar/administration/settings/general.md)
* [Release notes](https://wiki.datadike.com/sonar/release-notes.md)
