# Multiple Command-Node

This is an example showcasing how admins can remotely execute **_multiple commands_** via the "zero trust host access" control channel on specific nodes in Rafay MKS clusters operating in remote data centers.

* * *

## Request API

In this example, we want to send two distinct and separate commands to the specified nodes.

1. free -h
2. lsblk

As you can see, the two commands are sent together separated by a ";" in the highlighted line below.

```
curl --location --request POST 'https://console.rafay.dev/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execute/' \
--header 'X-RAFAY-API-KEYID: g5439debbd24b1c876aa79b4d2997bdca7009f3g' \
--header 'Content-Type: application/json' \
--data-raw '{\n    "target" : ["madhuarm-ubuntu201","madhuamd-ubuntu201"],\n    "target_type" : "node",\n    "command": "free -h ;lsblk",\n    "content_type": "string",\n    "timeout": 360\n}'
```

The output returns data and an "Exec ID" which can then be used to query for results of the responses.

* * *

### Retrieve Results

We will use the Exec ID to retrieve results.

```
curl --location --request GET 'https://console.rafay.dev/cmdexec/v1/projects/j2q4j5k/edges/3mxg7ek/execution/q6kn4ml/' \
--header 'X-RAFAY-API-KEYID: fg5439debbd24b1c876aa79b4d2997bdca7009f3g'
```

Shown below is an example of what the results can look like.

**_Example Output_**

```
{\n    "NodeResponses": [\
        {\
            "Name": "madhuamd-ubuntu201",\
            "Resp": {\
                "Return": "              total        used        free      shared  buff/cache   available\nMem:          7.5Gi       2.7Gi       1.7Gi       7.0Mi       3.2Gi       4.8Gi\nSwap:            0B          0B          0B\nNAME                                                                                MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT\nloop0                                                                                 7:0    0 55.4M  1 loop  /snap/core18/2128\nloop1                                                                                 7:1    0 55.4M  1 loop  /snap/core18/2066\nloop2                                                                                 7:2    0 61.8M  1 loop  /snap/core20/1081\nloop3                                                                                 7:3    0 67.6M  1 loop  /snap/lxd/20326\nloop4                                                                                 7:4    0 67.3M  1 loop  /snap/lxd/21545\nloop5                                                                                 7:5    0 66.8M  1 loop  /snap/oracle-cloud-agent/18\nloop6                                                                                 7:6    0 32.1M  1 loop  /snap/snapd/12057\nloop7                                                                                 7:7    0 58.3M  1 loop  /snap/oracle-cloud-agent/22\nloop8                                                                                 7:8    0 32.3M  1 loop  /snap/snapd/13170\nloop9                                                                                 7:9    0 61.9M  1 loop  /snap/core20/1169\nsda                                                                                   8:0    0 46.6G  0 disk  \n|-sda1                                                                                8:1    0 46.5G  0 part  /\n|-sda14                                                                               8:14   0    4M  0 part  \n`-sda15                                                                               8:15   0  106M  0 part  /boot/efi\nsdb                                                                                   8:16   0   50G  0 disk  \n`-heketi-vol                                                                        253:0    0   50G  0 crypt \n  |-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8_tmeta   253:1    0   12M  0 lvm   \n  | `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8-tpool 253:3    0    2G  0 lvm   \n  |   `-vg_64925849821aa380935843c7d35f3220-brick_cebecc9c7368267a1e561f7cc3606764  253:5    0    2G  0 lvm   \n  `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8_tdata   253:2    0    2G  0 lvm   \n    `-vg_64925849821aa380935843c7d35f3220-tp_fc9b8fcc4ee00788a5c7081563ce08c8-tpool 253:3    0    2G  0 lvm   \n      `-vg_64925849821aa380935843c7d35f3220-brick_cebecc9c7368267a1e561f7cc3606764  253:5    0    2G  0 lvm",\
                "Retcode": 0,\
                "Success": true\
            }\
        }\
    ],\
    "Responded": [\
        "madhuamd-ubuntu201"\
    ],\
    "Unreachable": [\
        "madhuarm-ubuntu201"\
    ],\
    "Unapproved": [],\
    "Pending": []\n}
```
