Sending Commands to Devices
Single Device Commands
Commands can be sent to one device at a time from the device detail page, as shown in the GIF below:
Click the Send Command button, select the command type and fill in the required inputs. The command is sent to the device and its status is shown in the Recent Commands section of the device detail page.
To send the same command to many devices at once, refer to Mass Commands.
Default Commands
By default, there are three options in the Send Command dropdown:
Reboot
Change Password
Custom Command
While the first two options are self-explanatory, the custom command option allows you to execute any command on the device as shown in the example below.
Important
In order for this feature to work, a device needs to have at least one valid Access Credential (see How to configure push updates).
The Send Command button will be hidden until the device has at least one Access Credential.
If you need to allow your users to quickly send specific commands that are used often in your network regardless of your users' knowledge of Linux shell commands, you can add new commands by following instructions in the Defining New Options in the Commands Menu section below.
Note
You can also use the REST API to execute commands on a device.
Mass Commands
Mass commands run the same command on many devices at once, for example to reboot all the devices of an organization, as shown in the GIF below:
Sending a Mass Command
Open Network Operations > Run Mass command.
Choose the command, a label to recognize it later, and the targets: organization, device group and location. Combining targets narrows the selection.
Review the matched devices, uncheck any you want to leave out, and click Execute.
Superusers can leave every target empty to run the command on all the devices, as shown in the GIF below:
Other users must choose at least one target and can only use the commands enabled for their organization (see OPENWISP_CONTROLLER_ORGANIZATION_ENABLED_COMMANDS).
From the Device List
A mass command can also be started from the device list, as shown in the GIF below:
Select the devices, choose Execute mass command from the actions dropdown and click Go. Then choose the command and review the devices as described above. The selected devices must belong to the same organization.
Following the Results
After executing, the mass command page shows the status and output of each device, updated in real time, as shown in the GIF below:
Devices which cannot run the command, for example because they have no access credentials, are marked as skipped together with the reason.
The output column shows only the last line of the output, limited to 100 characters.
If any device fails or is skipped, the mass command is marked as failed.
Past mass commands are listed in Network Operations > Mass commands.
Commands sent by a mass command also appear in the Recent Commands of each device, with a link back to the mass command.
REST API
Mass commands can also be sent and followed through the Batch Command API.
How to register or unregister commands
Refer to Registering / Unregistering Commands in the developer documentation.