Score:0

How to have terminator open tabs on tailing (less +F) log files on remote machines

in flag

I would like to develop a terminator layout that opens 4 tabs, having 3 of them showing log files on remote machines in tailing mode (less +F <logfile>) and the last one monitoring the content of a folder with command watch.

To better explain, this is what I would do manually as user to achieve what I want:

First, I would manually split terminator window into 4 tabs displayed as 2x2: 1 vertical split, 1 horizontal split

 1  |  2
----------
 3  |  4

Then in each tab I would run the following commands:

tab 1

ssh user_P@remote_machine_ip
sudo -i -u user_O
less +F /path/to/log1/log1.log

tab 2

ssh user_P@remote_machine_ip
sudo -i -u user_O
less +F /path/to/log2/log2.log

tab 3

ssh user_P@remote_machine_ip
sudo -i -u user_O
sudo less +F /path/to/log3/log3.log 

tab 4

ssh user_P@remote_machine_ip
sudo -i -u user_O
watch -n 1 ls /home/user_O/my_folder/
Score:2
in flag

1 - create and save the desired tabs disposition layout

This thread explains well how to do it.

start by opening terminator configuration file by running

xdg-open /home/your_local_user/.config/terminator/config


2 - Write the commands to run for each tab

Under the section [[your-custom-layout-name]] You have to add a key command = ... under each text snippet like

 [[[terminal<number>]]]
       type = Terminal

The content of each key command of your tab should be:

tab 1

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log

tab 2

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O sudo less +F /path/to/log2/log2.log

tab 3

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log

tab 4

command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O watch -n 1 ls /home/user_O/my_folder/

In the end your layout should look like this:

[global_config]
  enabled_plugins = LaunchpadBugURLHandler, LaunchpadCodeURLHandler, APTURLHandler, TerminalShot, SelectAll
  case_sensitive = False
[keybindings]
[profiles]
  [[default]]
    cursor_color = "#aaaaaa"
[layouts]
  [[default]]
    [[[window0]]]
      type = Window
      parent = ""
    [[[child1]]]
      type = Terminal
      parent = window0
      profile = default
  [[your-custom-layout-name]]
    [[[child0]]]
      type = Window
      parent = ""
      order = 0
      position = 0:0
      maximised = True
      fullscreen = False
      size = 1920, 773
      title = user_O@remote_machine_alias
      last_active_term = 99c695d1-9a3e-43bb-a424-55ed77e9e4e8
      last_active_window = False
    [[[child1]]]
      type = HPaned
      parent = child0
      order = 0
      position = 958
      ratio = 0.5002610966057441
    [[[child2]]]
      type = VPaned
      parent = child1
      order = 0
      position = 385
      ratio = 0.5013020833333334
    [[[terminal3]]]
      type = Terminal
      title = tab 1
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log1/log1.log
      parent = child2
      order = 0
      profile = default
      uuid = 6cebd0a2-f543-41e9-8cb4-dcfad9feb41c
    [[[terminal4]]]
      type = Terminal
      title = tab 3
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O less +F /path/to/log3/log3.log
      parent = child2
      order = 1
      profile = default
      uuid = d328e8b6-8822-4880-b9d6-97ca87cae185
    [[[child5]]]
      type = VPaned
      parent = child1
      order = 1
      position = 385
      ratio = 0.5013020833333334
    [[[terminal6]]]
      type = Terminal
      title = tab 2
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O sudo less +F /path/to/log2/log2.log
      parent = child5
      order = 0
      profile = default
      uuid = 99c695d1-9a3e-43bb-a424-55ed77e9e4e8
    [[[terminal7]]]
      type = Terminal
      title = tab 4
      command = ssh -t -o ConnectTimeout=3 user_P@remote_machine_ip sudo -i -u user_O watch -n 1 ls /home/user_O/my_folder/
      parent = child5
      order = 1
      profile = default
      uuid = 777a548f-868b-4a80-81d7-5cf973de5cad
[plugins]

In the end, open terminator with your custom layour from your terminal

terminator -l your-custom-layout-name

Warning:

Every tab in less/watch must be stopped with CTRL+C before being closed from terminator UI, otherwise the less/watch processes will continue in background mode, draining your CPU.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.