9. How to setup an SSH Monitor daemon#
Running an IOC program as a daemon is really convenient in production. It’s very useful - among other things - in order to log the IOC Shell, in order to allow multiple users to share the same IOC Shell screen at the same time, in order to access and leave the IOC Shell at any point in time without having to restart the IOC program, etc.
If you wonder how to daemonize an IOC program, here are
two suggestions with procServ and tmux.
9.1. procServ daemon#
Prerequisites:
Install the
procServpackage on your host’s Linux distribution:E.g. with
apt:$ sudo apt install procservE.g. with
yum:$ sudo yum install procservE.g. with
dnf:$ sudo dnf install procserv
procServ can be used as an easy daemonizer,
e.g. with the SSH Monitor IOC program
used as an example in the .cmd and .substitutions how-to:
$ procServ -n "sshmonitorTarget1" -c /path/to/myTargetMonitoringTop/iocBoot/iocMyTargetMonitoring/ -i ^D^C 20000 ./st_target1.cmd
Important
With the above command,
the procServ instance associated to the IOC program is attached to the TCP port 20000.
You want to make sure to use different and unique TCP port numbers
for each new procServ instance associated to other IOC programs
(that are run in parallel).
9.2. procServ tips#
Find
procServPID:$ pgrep procServ $ ps -aux | grep "procServ"
Find the SSH Monitor IOC program (running inside
procServ) PID:$ pgrep sshmonitorTarget1 $ ps -aux | grep "sshmonitorTarget1"
Restart the SSH Monitor IOC program (running inside
procServ) by just killing it:procServwill restart it automatically:$ pgrep sshmonitorTarget1 > 123123 $ sudo kill -9 123123
Connect locally to
procServ:$ telnet 127.0.0.1 20000
Quit
procServ- without stopping the IOC program - by enteringCtrl + AltGr + ]and then enterquit.Connect remotely to
procServ:$ ssh host-username@<host-ip-address> -t telnet 20000
See also
For more details about procServ, see ralphlange/procServ
9.3. tmux daemon#
Prerequisites:
Install the
tmuxpackage on your Linux distribution:E.g. with
emerge:$ sudo emerge -a app-misc/tmuxE.g. with
pacman:$ sudo pacman -S tmuxE.g. with
apt:$ sudo apt install tmuxE.g. with
yum:$ sudo yum install tmuxE.g. with
dnf:$ sudo dnf install tmux
tmux can also be used as an easy daemonizer,
e.g. with the SSH Monitor IOC program
used as an example in the .cmd and .substitutions how-to:
$ tmux new-session -d -s sshmonitorTarget1 'cd /path/to/myTargetMonitoringTop/iocBoot/iocsshmonitor && ./st_target1.cmd'
9.4. tmux tips#
Enter your
sshmonitorTarget1tmuxsession (i.e. your {SSH_Monitor}} IOC Shell fortarget1):$ tmux a -t sshmonitorTarget1
Help screen (Q to quit):
Ctrl+b ?Scroll in window:
Ctrl+b PageUp/PageDownEnter scroll mode:
Ctrl+b [
(then up/down arrow keys and/or pageup/pagedown)
Exit scroll mode:
> qDetach from
tmuxwithout stopping the IOC program:Ctrl+b d
Stop the
tmuxdaemon and associated IOC program:$ tmux kill-session -t sshmonitorTarget1
List currently running
tmuxdaemons:$ tmux ls # or `$ tmux list-sessions`
See also
For more details about tmux, see: