Description

Having multiple panes in tmux allows you to execute the same set of commands on multiple or all panes at exactly the same time.

In a Contrail environment, for example, you may want to:

  • Monitor the same log file at the same time, but from different contrail nodes.
  • Repeat the same packet capture command in multiple compute nodes.

Refer to the tmux wiki for further details.

Solution

The Tmux solution is to synchronize the panes by pressing 'ctrl+b ' then press ':' (colon). This will allow you entering the Tmux command mode:

    | aba2b81e-da76-41bf-91c7-68df46346522 | vm-pings-ne│  Usage of /:   10.7% of 109.88GB   Users logged in:
    t-cirros-3  | ACTIVE | -          | Running     | pi│ 0
    ngs-net2=2.2.2.8                                  | │  Memory usage: 69%                 IP address for eth0:
    | a96a8597-34c8-4919-a5d0-c645be178398 | vm-pings-ne│ 10.85.188.5
    t-firefly-1 | ACTIVE | -          | Running     | pi│  Swap usage:   0%                  IP address for eth1:
    ngs-net2=2.2.2.3; pings-net=1.1.1.5; mgmt=3.3.3.3 | │ 10.169.4.5
    | 6ad30294-a236-4e1a-a411-0bac40aa9105 | vm-pings-ne│
    t-firefly-2 | ACTIVE | -          | Running     | pi│  Graph this data and manage this system at:
    ngs-net2=2.2.2.6; pings-net=1.1.1.7; mgmt=3.3.3.5 | │    https://landscape.canonical.com/
    | 6a64b345-8801-4727-93b4-03661aa9e75d | vm-pings-ne│
    t-ubuntu-1  | ACTIVE | -          | Running     | pi│*** System restart required ***
    ngs-net=1.1.1.4                                   | │Last login: Fri Jun 25 12:07:29 2021 from pings-t490.jnp
    +--------------------------------------+------------│r.net
    ------------+--------+------------+-------------+---│root@cont45:~#
    --------------------------------------------------+ │root@cont45:~#
    root@cont44:~#                                      │root@cont45:~#
    ────────────────────────────────────────────────────┼────────────────────────────────────────────────────────
    prefix v14.15.1 --silent` to unset it.              │ process
    [2021-06-25 15:49:01]pings@pings-T490:~             │  soft                 Soft reset (SIGHUP) the process
    $                                                   │  |                    Pipe through a command
    [2021-06-28 17:17:40]pings@pings-T490:~             │labroot@camaro> restart firewall
    $                                                   │Jun 25 20:21:49
    [2021-06-28 17:17:40]pings@pings-T490:~             │Firewall process started, pid 23334
    $ clear                                             │
    [2021-06-28 17:17:42]pings@pings-T490:~             │labroot@camaro>
                                                        │[2021-06-25 22:49:57]pings@pings-T490:~
                                                        │$
    :    <--- command mode prompt

The ' : ' (colon) in the bottom of this capture is the prompt for Tmux command mode. From this moment on, whatever characters you press will be treated as Tmux configurations.

Command to "synchronize" all panes:

    setw synchronize-panes on

After pressing Enter , the command you just typed will be accepted by Tmux. The command entered above will synchronize all panes in the current window. Any keystroke you type in any pane will be cloned and sent to all other panes at the same time. Below is a screen captured in the middle of typing ' contrail-status -d' command:

    | aba2b81e-da76-41bf-91c7-68df46346522 | vm-pings-ne│  Usage of /:   10.7% of 109.88GB   Users logged in:
    t-cirros-3  | ACTIVE | -          | Running     | pi│ 0
    ngs-net2=2.2.2.8                                  | │  Memory usage: 69%                 IP address for eth0:
    | a96a8597-34c8-4919-a5d0-c645be178398 | vm-pings-ne│ 10.85.188.5
    t-firefly-1 | ACTIVE | -          | Running     | pi│  Swap usage:   0%                  IP address for eth1:
    ngs-net2=2.2.2.3; pings-net=1.1.1.5; mgmt=3.3.3.3 | │ 10.169.4.5
    | 6ad30294-a236-4e1a-a411-0bac40aa9105 | vm-pings-ne│
    t-firefly-2 | ACTIVE | -          | Running     | pi│  Graph this data and manage this system at:
    ngs-net2=2.2.2.6; pings-net=1.1.1.7; mgmt=3.3.3.5 | │    https://landscape.canonical.com/
    | 6a64b345-8801-4727-93b4-03661aa9e75d | vm-pings-ne│
    t-ubuntu-1  | ACTIVE | -          | Running     | pi│*** System restart required ***
    ngs-net=1.1.1.4                                   | │Last login: Fri Jun 25 12:07:29 2021 from pings-t490.jnp
    +--------------------------------------+------------│r.net
    ------------+--------+------------+-------------+---│root@cont45:~#
    --------------------------------------------------+ │root@cont45:~#
    root@cont44:~# contrail-status -                    │root@cont45:~# contrail-status -
    ────────────────────────────────────────────────────┼────────────────────────────────────────────────────────
      System load:  0.54                Processes:      │  Memory usage: 59%                IP address for vhost0
         234                                            │: 10.169.4.7
      Usage of /:   13.1% of 109.88GB   Users logged in:│  Swap usage:   0%                 IP address for virbr0
         0                                              │: 192.168.122.1
      Memory usage: 69%                 IP address for e│  Processes:    221
    th0: 10.85.188.6                                    │
      Swap usage:   1%                  IP address for e│  Graph this data and manage this system at:
    th1: 10.169.4.6                                     │    https://landscape.canonical.com/
                                                        │
      Graph this data and manage this system at:        │New release '16.04.7 LTS' available.
        https://landscape.canonical.com/                │Run 'do-release-upgrade' to upgrade to it.
                                                        │
    *** System restart required ***                     │Last login: Fri Jun 25 08:32:23 2021 from pings-t490.jnp
    Last login: Fri Jun 25 12:07:41 2021 from pings-t490│r.net
    .jnpr.net                                           │root@comp47:~#
    root@cont46:~#                                      │root@comp47:~#
    root@cont46:~#                                      │root@comp47:~#
    root@cont46:~# contrail-status -                    │root@comp47:~# contrail-status -

Note that the last character 'd' is not typed yet, but the typed part 'contrail-status -' appears in all Tmux panes. After completing the command, press 'enter' . The ' contrail-status -d ' will be sent to all contrail nodes. Pane synchronization will no longer be needed and can be disabled.

To disable pane synchronization, enter Tmux command mode first:

    ctrl-b + :

Then type the following command:

    setw synchronize-panes off


This process may seem tedious. For a set of Tmux configurations which includes a Tmux command to "bind" the whole process of enabling and disabling pane synchronize into one single keystroke to simplify the operation, refer to KB37204 - How to use Tmux in contrail setup - Customized configuration [juniper.net]