Skip to main content

SSH

SSH can be used to download a file from a server or to execute remote commands on a server, for example to get the current workload or disk usage. The authentication for the SSH connection are defined in a secret.

Datasource​

Create a new secret with field type set to ssh. Define the other parameters such as the IP address or name of host, the username and password and optionally a specific port number. In the field filename enter the path to the file. You can protect confidential information in the secret by clicking on the lock.

Importer​

In the importer enter the name of the secret under Datasource and select Test to retrieve the data. Note that this may take a few seconds for setting up an SSH connection and logging in to the host.

Executing remote commands​

You can also use an SSH connection to execute remote commands. In the example below the keys are mapped to a JavaScript function exec(command, options). The command is a linux command that is executed on the server to get the load and disk usage.

top -b -n 2 | grep 'Cpu' | cat | awk '{print $2}'|tail -1
df /dev/vda3 | awk '{print $5}'| tail -1 | sed s/%//

The field options is mapped to the column secret in the data source.