Description

The articles listed below introduced how to use tmux in RHOST13 based Contrail environment to smooth the operation workflow. This article introduces another prevailing use case of tmux in production: sharing the session.

Related Articles:

Solution

During team collaborations, it is often desired to share the current problem under debugging to other team members or experts from outside of the team to seek more support. Describing the full login steps are tedious abd capturing the issues into a ticket may not be efficient under time pressure. Tmux enables each client to "share" the same session, similar to screen sharing in many meeting applications, but instead of sharing the entire "screen", only the tmux session (ascii text in console) is shared. 

Example Scenario:

User1 created a tmux session with session name "jtac", as described in KB37199 [juniper.net] . User1 runs into a problem and wants to invite two other users (user2 and user3) to see the issue. The other users only need to login to the RHOST13 host and "attach" to the same "jtac" session.

    user2                                                          user3
    $ ssh [email protected]                                         │$ ssh [email protected]
    [email protected]'s password:                                   │[email protected]'s password:
    Last login: Sun Sep 26 08:48:11 2021 from pings-t490.jnpr.net  │Last login: Sun Sep 26 08:53:20 2021 from pings-t490.jnpr.net
    [root@global-intel17 ~]# ssh stack@undercloud                  │[root@global-intel17 ~]# ssh stack@undercloud
    Last login: Sun Sep 26 11:48:04 2021 from 192.168.122.1        │Last login: Sun Sep 26 11:53:27 2021 from 192.168.122.1
    [stack@queensa ~]$ tmux ls                                     │[stack@queensa ~]$ tmux ls
    jtac: 1 windows (created Thu Sep  9 09:43:28 2021) [239x27]    │jtac: 1 windows (created Thu Sep  9 09:43:28 2021) [239x27]
    [stack@queensa ~]$                                             │[stack@queensa ~]$

    [stack@queensa ~]$ tmux attach -t jtac                         │[stack@queensa ~]$ tmux attach -t jtac

Then the tmux session becomes visible for all three users. Each user can view the screen and type commands, which makes it easier to demonstrate and discuss any problems.

    user2                                                           user3
    | b07cf898-d094-4dfc-9f0b-b8d038879bca | control          [0/9]│| b07cf898-d094-4dfc-9f0b-b8d038879bca | control            |  │
    | bf0dbcb8-9a29-449b-a0da-f5547f3cf6b7 | compute-dpdk       |  │| bf0dbcb8-9a29-449b-a0da-f5547f3cf6b7 | compute-dpdk       |  │
    | e782effe-8a21-49f2-a77c-24d28040c2a5 | contrail-analy     |  │| e782effe-8a21-49f2-a77c-24d28040c2a5 | contrail-analy     |  │
    | fdb2952e-272d-40a3-adb3-6afb8cd2bf0c | ceph-storage       |  │| fdb2952e-272d-40a3-adb3-6afb8cd2bf0c | ceph-storage       |  │
    +--------------------------------------+--------------------+  │+--------------------------------------+--------------------+  │
    (undercloud) (undercloud) [root@queensa ~]#                    │(undercloud) (undercloud) [root@queensa ~]#                    │
    You have mail in /var/spool/mail/root                          │You have mail in /var/spool/mail/root                          │
    (undercloud) (undercloud) [root@queensa ~]# ls                 │(undercloud) (undercloud) [root@queensa ~]# ls                 │
    anaconda-ks.cfg  cirros051.img  original-ks.cfg  pings-        │anaconda-ks.cfg  cirros051.img  original-ks.cfg  pings-        │
    (undercloud) (undercloud) [root@queensa ~]#                    │(undercloud) (undercloud) [root@queensa ~]#                    │
    (undercloud) (undercloud) [root@queensa ~]# tmux ls            │(undercloud) (undercloud) [root@queensa ~]# tmux ls            │
    failed to connect to server                                    │failed to connect to server                                    │
    (undercloud) (undercloud) [root@queensa ~]#   session "jtac"   │(undercloud) (undercloud) [root@queensa ~]#     session "jtac" │
    (undercloud) (undercloud) [root@queensa ~]#   pane 0           │(undercloud) (undercloud) [root@queensa ~]#     pane 0         │
    (undercloud) (undercloud) [root@queensa ~]#                    │(undercloud) (undercloud) [root@queensa ~]#                    │
    (undercloud) (undercloud) [root@queensa ~]# d                  │(undercloud) (undercloud) [root@queensa ~]# d                  │
    -bash: d: command not found                                    │-bash: d: command not found                                    │
    (undercloud) (undercloud) [root@queensa ~]#                    │(undercloud) (undercloud) [root@queensa ~]#                    │
    (undercloud) (undercloud) [root@queensa ~]#                    │(undercloud) (undercloud) [root@queensa ~]#                    │
    (undercloud) (undercloud) [root@queensa ~]# ls                 │(undercloud) (undercloud) [root@queensa ~]# ls                 │
    anaconda-ks.cfg  cirros051.img  original-ks.cfg  pings-        │anaconda-ks.cfg  cirros051.img  original-ks.cfg  pings-        │
    (undercloud) (undercloud) [root@queensa ~]# docker p           │(undercloud) (undercloud) [root@queensa ~]# docker p           │
    ───────────────────────────────────────────────────────────────│───────────────────────────────────────────────────────────────┤
    export OS_NO_CACHE=True                       session "jtac"   │export OS_NO_CACHE=True                         session "jtac" │
    export COMPUTE_API_VERSION=1.1                pane 1           │export COMPUTE_API_VERSION=1.1                  pane 1         │
    export OS_USERNAME=admin                                       │export OS_USERNAME=admin                                       │
    export no_proxy=,10.85.65.142,192.168.24.6                     │export no_proxy=,10.85.65.142,192.168.24.6                     │
    export OS_REGION_NAME=regionOne                                │export OS_REGION_NAME=regionOne                                │
    export OS_USER_DOMAIN_NAME=Default                             │export OS_USER_DOMAIN_NAME=Default                             │
    export OS_VOLUME_API_VERSION=3                                 │export OS_VOLUME_API_VERSION=3                                 │
    export OS_CLOUDNAME=overcloud                                  │export OS_CLOUDNAME=overcloud                                  │
    export OS_AUTH_URL=http://10.85.65.142:5000//v3                │export OS_AUTH_URL=http://10.85.65.142:5000//v3                │
    export NOVA_VERSION=1.1                                        │export NOVA_VERSION=1.1                                        │
    export OS_IMAGE_API_VERSION=2                                  │export OS_IMAGE_API_VERSION=2                                  │
    export OS_PASSWORD=z8DrkCB3nQMAGFbE7ZHuNZmE7                   │export OS_PASSWORD=z8DrkCB3nQMAGFbE7ZHuNZmE7                   │
    export OS_PROJECT_DOMAIN_NAME=Default                          │export OS_PROJECT_DOMAIN_NAME=Default                          │
    export OS_IDENTITY_API_VERSION=3                               │export OS_IDENTITY_API_VERSION=3                               │
    export OS_PROJECT_NAME=admin                                   │export OS_PROJECT_NAME=admin                                   │
    export OS_AUTH_TYPE=password                                   │export OS_AUTH_TYPE=password                                   │
    export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true│export PYTHONWARNINGS="ignore:Certificate has no, ignore:A t   │
                                                                   │                                                               │
    # Add OS_CLOUDNAME to PS1                                      │# Add OS_CLOUDNAME to PS1                                      │
    if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then                     │if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then                     │
        export PS1=${PS1:-""}                                      │    export PS1=${PS1:-""}                                      │
        export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1      │    export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1      │
        export CLOUDPROMPT_ENABLED=1                               │    export CLOUDPROMPT_ENABLED=1                               │
    fi                                                             │fi                                                             │
    (undercloud) [stack@queensa ~]$                                │(undercloud) [stack@queensa ~]$                                │


To list all clients attached to the session, press " ctl b ", then " : " to enter tmux command mode, then type:

    listen-clients

All clients viewing the current session are listed:

    /dev/pts/3: jtac [118x59 screen-256color] (utf8) 
    /dev/pts/4: jtac [120x59 screen-256color] (utf8) 
    /dev/pts/0: jtac [239x28 xterm] (utf8)