viam-agent
The viam-agent is a self-updating service manager that maintains the lifecycle for itself and the following system services:
viam-server: the core of the machineagent-provisioning: device provisioning which can set up machine configs and manage WiFi networks. For more information see Provisioning.agent-syscfg: provides various operating system and system configuration tweaks
Among other things, viam-agent:
- Installs, runs, and monitors
viam-serverYou can also use a custom build ofviam-server, if needed. - Provides automatic updates for
viam-serverand the agent itself. - Allows control of deployed software versions through the Viam app.
Support notice
Currently, viam-agent is only supported on Linux, for amd64 (x86_64) and arm64 (aarch64) CPUs.
To provision machines using viam-agent, see
Installation
You can install viam-agent using either an existing machine’s part ID and API key, or using an existing machine credentials configuration file at
Important
Your machine must have curl available in order to install viam-agent.
- The first step is to add a new machine in the Viam app.
- Navigate to the CONFIGURE tab and find your machine’s card. An alert will be present directing you to Set up your machine part:
Click View setup instructions to open the setup instructions.
Then navigate to the machine part’s setup and follow the instructions to install viam server with viam-agent.
The command will be of the following form:
sudo /bin/sh -c "VIAM_API_KEY_ID=<KEYID> VIAM_API_KEY=<KEY> VIAM_PART_ID=<PARTID>; $(curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent/install.sh)"
Note
As an alternative to specifying the VIAM_API_KEY_ID, the VIAM_API_KEY, and the VIAM_PART_ID when running the command, you can also copy the viam-server app JSON configuration from the Viam app into
Then run the following command to install viam-agent:
sudo /bin/sh -c "$(curl -fsSL https://storage.googleapis.com/packages.viam.com/apps/viam-agent/install.sh)"
viam-agent will install itself as a systemd service named viam-agent.
For information on managing the service, see Manage viam-agent.
Configuration
Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Click the + icon next to your machine part in the left-hand menu and select Agent.
Edit and fill in the attributes as applicable.
{
"agent": {
"viam-agent": {
"release_channel": "stable",
"pin_version": "",
"pin_url": ""
},
"viam-server": {
"release_channel": "stable",
"pin_version": "",
"pin_url": "",
"disable_subsystem": false,
"attributes": {
"fast_start": false
}
},
"agent-provisioning": {
"disable_subsystem": false,
"networks": []
},
"agent-syscfg": {
"disable_subsystem": false
}
}
}
{
"agent": {
"viam-agent": {
"pin_version": "1.2.3"
},
"viam-server": {
"attributes": {
"fast_start": true
}
},
"agent-provisioning": {
"attributes": {
"hotspot_password": "acme123",
"networks": [
{
"type": "wifi",
"ssid": "fallbackNetOne",
"psk": "myFirstPassword",
"priority": 30
},
{
"type": "wifi",
"ssid": "fallbackNetTwo",
"psk": "mySecondPassword",
"priority": 10
}
]
}
},
"agent-syscfg": {
"attributes": {
"logging": {
"disable": false,
"system_max_use": "128M",
"runtime_max_use": "96M"
},
"upgrades": {
"type": "all"
}
}
}
}
}
viam-agent
| Option | Type | Required? | Description |
|---|---|---|---|
release_channel |
string | Optional | viam-agent is semantically versioned and is tested before release. Releases happen infrequently. When set to "stable", viam-agent will automatically upgrade when a new version is released. Options: "stable" (default). |
pin_version |
string | Optional | Use a specific version for viam-agent (as provided by the release channel). If set, no automatic upgrades will be performed until the setting is updated to a new version (or removed to revert to the release channel). If both pin_url and pin_version is set, pin_url will be used. Default: "". |
pin_url |
string | Optional | Ignore normal version selection and directly download from the specified URL. If set, no automatic upgrades will be performed until the setting is updated to a new URL (or removed to revert to the release channel). Typically this is only used for testing/troubleshooting. If both pin_url and pin_version is set, pin_url will be used. Default: "". |
viam-server
| Option | Type | Required? | Description |
|---|---|---|---|
release_channel |
string | Optional | viam-agent is semantically versioned and is tested before release. Releases happen infrequently. When set to "stable", viam-agent will automatically upgrade when a new version is released. Options: "stable" (default), "latest". |
pin_version |
string | Optional | Use a specific version for viam-server (as provided by the release channel). If set, no automatic upgrades will be performed until the setting is updated to a new version (or removed to revert to the release channel). If both pin_url and pin_version is set, pin_url will be used. Default: "". |
pin_url |
string | Optional | Ignore normal version selection and directly download from the specified URL. If set, no automatic upgrades will be performed until the setting is updated to a new URL (or removed to revert to the release channel). Typically this is only used for testing/troubleshooting. If both pin_url and pin_version is set, pin_url will be used. Default: "". |
disable_subsystem |
boolean | Optional | When set to true it disables the management of viam-server. |
attributes |
object | Optional |
|
Version updates
When a new version of viam-server becomes available, viam-agent will restart and upgrade viam-server immediately.
To limit when viam-server can be updated, you can configure a Maintenance Window.
With a configured maintenance window, viam-agent will restart and upgrade viam-server only when maintenance is allowed and when viam-server is not currently processing config changes.
Fast start mode
You can use fast start mode to bypass viam-agent waiting for a network connection to be established and checking for updates during initial startup.
This will result in viam-server executing as quickly as possible.
This is useful if you have a device that often starts when offline or on a slow connection, and if having the latest version immediately after start isn’t required.
Note
Period update checks will continue to run afterwards. The fast start mode only affects the initial startup sequencing.
You can also start viam-agent in fast start mode by setting VIAM_AGENT_FAST_START=1 in your environment.
agent-provisioning
| Option | Type | Required? | Description |
|---|---|---|---|
disable_subsystem |
boolean | Optional | When set to true it disables agent-provisioning management. |
attributes |
object | Optional | You can override all attributes from the viam-agent configuration file here. The viam-agent configuration file is generally customized by the manufacturer to provide “out of the box” settings. The attributes configured in the machine config in the Viam app can let you as the machine user override those if you wish. For security purposes, you should change the hotspot_password. You can also configure roaming_mode and add any additional networks you want to configure.
|
Networks
For an already-online device, you can configure new WiFi networks in the machine’s viam-agent configuration in the Viam app.
It’s primarily useful for a machine that moves between different networks, so the machine can automatically connect when moved between locations.
To add additional networks add them using the JSON editor for your device’s config in the Viam app.
Important
You must enable roaming_mode in the agent-provisioning configuration to allow the machine to connect to the specified networks.
Note that if you are using the Viam app to add networks to a machine’s configuration, the machine will need to be connected to the internet to retrieve the configuration information containing the network credentials before it can use them.
If roaming_mode is enabled, agent-provisioning will try to connect to each specified network in order of priority from highest to lowest.
If the highest-priority network is not available or the machine can connect but internet is not available, viam-agent will then attempt to connect to the next-highest network, and so on until all configured networks have been tried.
| Name | Type | Description |
|---|---|---|
type |
string | The type of the network. Options: "wifi" |
ssid |
string | The network’s SSID. |
psk |
string | The network pass key. |
priority |
int | Priority to choose the network with. Values between -999 and 999. Default: 0. |
The following configuration defines the connection information and credentials for two WiFi networks named fallbackNetOne and fallbackNetTwo:
...
"agent": {
"agent-provisioning": {
...
"attributes": {
...
"roaming_mode": true,
"networks": [
{
"type": "wifi",
"ssid": "fallbackNetOne",
"psk": "myFirstPassword",
"priority": 30
},
{
"type": "wifi",
"ssid": "fallbackNetTwo",
"psk": "mySecondPassword",
"priority": 10
}
]
}
}
}
agent-syscfg
agent-syscfg is a plugin for viam-agent that allows you to configure logging settings and automated upgrades for packages installed on the operating system.
| Option | Type | Required? | Description |
|---|---|---|---|
disable_subsystem |
boolean | Optional | When set to true it disables agent-syscfg. |
attributes |
object | Optional |
|
The following configuration allows all upgrades from configured sources and sets the maximum disk space journald will user for persistent log storage to 128MB and the runtime limit to 96MB:
"agent-syscfg": {
"release_channel": "stable",
"attributes": {
"logging": {
"disable": false,
"system_max_use": "128M",
"runtime_max_use": "96M"
},
"upgrades": {
"type": "all"
}
}
}
Version management for viam-agent and viam-server
By default, viam-agent automatically updates both itself and viam-server as new updates are released.
You can configure update behavior using the Viam app.
To ensure that updates only occur when your machines are ready, configure a maintenance window.
To use a specific version of viam-agent and viam-server, you can pin the version.
Important
When viam-agent updates itself, you must restart viam-agent or reboot in order to use the new version.
When you stop or restart viam-agent, the agent will stop or restart viam-server as well.
When viam-server updates itself, you must restart viam-server in order to use the new version.
You can restart viam-server from the machine’s part status dropdown to the right of your machine’s name on its page in the Viam app.
For more information on managing viam-agent see:
Agent logs
viam-agent writes log messages to the Viam app.
You can find these messages on the LOGS tab of your machine’s page.
viam-agent only sends messages when your machine is online and connected to the internet.
If your machine is offline, log messages are queued and are sent to the Viam app once your machine reconnects to the internet.
These log messages include when viam-server is stopped and started, the status of viam-agent, and any errors or warnings encountered during operation.