Skip to main content
Documentation

Run a Fleet Operation

Run a device command on the devices of a project in two stages: first on 10% of the devices, then, once they succeeded, on all others. This example runs the uptime command from Create a Device Command; replace it with a command that your devices publish.

Before You Start

You need a project with devices and permission to manage them, on a Nexigon Hub instance with operations enabled. The Operations entry in the project’s sidebar appears only then.

The devices fetch command steps from Nexigon Hub only with custom commands and operation polling enabled in their agent configuration. Restart the agent after changing it:

/etc/nexigon/agent.toml
[commands]
enabled = true

[operations]
enabled = true

An idle device checks for new work every 60 seconds by default. Commands in Operations explains the setting.

Create the Operation

  1. Open Operations in the project’s sidebar and choose New Operation.
  2. Enter a name, such as Collect uptime.
  3. Under Targets, keep the group conditions and Expression empty to select all devices of the project. The preview below shows the devices that match now. Keep Selection at Devices that match when it starts.
  4. Under Steps, keep the Run Command step, enter uptime as Command, and enter {} as Input (JSON).
  5. Under Stages, choose Add Stage. The new first stage contains 10% of the matching devices. The last stage, Everything, contains all others. Its guard releases it once all devices of the first stage have succeeded.
  6. Enter a Deadline (hours), such as 24, so that offline devices time out instead of keeping the operation open.
  7. Choose Create Operation. The operation stays a draft until you start it.

Start and Review the First Stage

Choose Start. Nexigon Hub selects the targets and releases the first stage. The Targets table shows each device’s stage and status, and under Result the command’s output, which contains uptime_secs, or the error.

Once every target of the first stage has succeeded, Nexigon Hub releases the second stage. If a device of the first stage stays offline, its target times out at the deadline and holds back the second stage, because the guard allows no failures. Choose Release Next Stage to release it anyway.

Halt or Cancel

  • Halt stops the operation from releasing stages and handing out work, for example while you investigate a failure. Devices still report the results of commands that they already received. Resume continues where it stopped.
  • Cancel stops the operation permanently and cancels its unfinished targets.

Once all targets have finished, the operation is completed, or failed if a target failed or timed out. The Targets table shows the errors of failed targets.

Next Steps

The Operations Reference describes the other steps, such as property changes and waits for a device’s response, step conditions, and the API actions.