Unix - Actively Monitor Multiple Logs

On Unix like systems, a handy method to monitor multiple logs simultaneously is combining tmux and lnav (consult your OS for installing these utilities)

This example will actively monitor /var/log/syslog; /sbbs/data/sbbsecho.log; /sbbs/exec/umonitor

setup tmux

First, setup tmux to have 3 panes start with a bash script similar to:

#!/bin/sh
tmux new-session -s "Whatever Tmux" -d
tmux split-window -v
tmux split-window -h
tmux -2 attach-session -d  

Once tmux has started you'll see three panes each with a command prompt. Depending on how your tmux key bindings are setup, (this example uses the default bindings CTRL+B+<arrow_key>) navigate to each pane and launch your desired app.

This example uses the top full width pane to monitor /var/log/syslog as it is the most verbose of our active monitoring:

$ sudo lnav /var/log/syslog

Next, navigate to one of the split horizontal panes at the bottom of the window:

$ lnav /sbbs/data/sbbsecho.log 

Lastly, navigate to the 3rd pane:

$ /sbbs/exec/umonitor

You should now have 3 panes, each monitoring one aspect of you Synchronet BBS activity.

example image

Advanced tmux example

In this example, we create a bash script that sets tmux up for us and automatically launches a few goodies:

me@localhost: $ nano sbbsmux
#!/bin/bash
# sbbsMux - SBBS Monitoring script
tmux new-session -d -s sess >/dev/null
tmux rename-window -t sess:0 'AlleyCat'
tmux splitw -v -p 20 -t sess:0.0
tmux splitw -h -p 80 -t sess:0.1
#required; otherwise pane numbering is bs
tmux select-pane -t sess:0.0
tmux splitw -h -p 5 -t sess:0.0
tmux send-keys -t sess:0.0 'lnav' Enter
tmux send-keys -t sess:0.2  'sudo htop -u pi' Enter
tmux send-keys -t sess:0.1 '/sbbs/exec/umonitor' Enter
tmux select-pane -t sess:0.0
tmux new-window -t sess
tmux rename-window -t sess:1 'BBS'
tmux splitw -v -p 10 -t sess:1.0
tmux splitw -h -p 80 -t sess:1.1
tmux select-pane -t sess:1.0
tmux splitw -h -p 10 -t sess:1.0
tmux clock -t sess:1.1
tmux new-window -t sess
tmux rename-window -t sess:2 'Monitor'
tmux splitw -v -p 10 -t sess:2.0
tmux send-key -t sess:2.0 'lnav /sbbs/data/sbbsecho.log' Enter
tmux select-pane -t sess:2.0
tmux splitw -h -p 5 -t sess:2.0
tmux clock -t sess:2.1
tmux select-window -t sess:0.0
tmux a -t sess

note Edit 'tmux rename-window -t sess:x 'Accordingly'

Save this as sbbsmux (or whatever) and chmod +x and launch it

someone@somewhere: $ ./sbbsmux

The output should look similar to:

Navigate to the pane with the prompt, this was left available to preforming tasks. Here we will launch another monitoring tool:

me@mynixbox: $ lnav /sbbs/data/sbbsecho.log

Now we should see something similar to:

See Also