Simultaneously monitoring multiple log files (over ssh) on Windows?
-
01-07-2019 - |
Question
I've used poderosa(a .NET terminal app) to monitor logs on multiple linux/solaris servers. This application is NOT getting currently maintained and I've had several problems with it.
I'm wondering what other users do to simultaneously monitor several logs in real-time(as in tail -f logfile). I would like to be able to tab/cascade several ssh tails.
thank you
Solution
You could use Putty Connection Manager to add tabs to PuTTy. Then SSH into the machine twice and tab back and forth.
OTHER TIPS
You could just ssh to one server, and use mutitail from there to tail the logs on all the other servers.
Ssh to one of the server, run screen on it. You can then split the screen into multiple windows, and each one of them do
ssh serverX tail -f /path/to/log/file
An incidental advantage to this method is that you don't have to restart the tails each time you connect - instead, you can just reattach to the running screen session.
From bash you can (save in ~/.bashrc
or something):
function create-follower () {
local _NAME=$1;
local _USER=$2;
local _HOST=$3;
local _PATH=$4;
if ! [ "${_NAME}" ]\
|| ! [ "${_USER}" ]\
|| ! [ "${_HOST}" ]\
|| ! [ "${_PATH}" ] ; then
{ echo "Cannot create log follower." ;
echo;
echo "Usage: create-follower NAME USER HOST LOG-FILE";
} >&2;
return 1 ;
fi ;
eval "function ${_NAME}(){ ssh ${_USER}@${_HOST} tail -f \"${_PATH}\" & }"
}
function activate-followers () {
if (( $# < 1 )) ; then
{ echo "You must specify at least one follower to use" ;
echo ;
echo "Usage:" ;
echo " activate-followers follower1 [follower2 ... followerN]";
} >&2;
return 1 ;
fi ;
for FOLLOW in "${@}" ; do
${FOLLOW} ;
done ;
wait;
}
function stop-followers () {
if [ "$(jobs)" ] ; then
kill -9 $(jobs | perl -pe 's/\[([0-9]+)\].*/%$1/') ;
fi ;
}
And then from your shell, define the logs you want to follow:
[dsm@localhost:~]$ create-follower test1 user1 localhost /tmp/log-1.txt
[dsm@localhost:~]$ create-follower test2 user2 otherhost /tmp/log-2.txt
[dsm@localhost:~]$ create-follower test2 user3 remotebox /tmp/log-3.txt
Now, activate the followers:
[dsm@localhost:~]$ activate-followers test1 test2 test3
To get out of the function use CTRL+C
, and to stop the backgrounded processes use:
[dsm@localhost:~]$ stop-followers
NOTE 1: This assumes public key authentication has been set up for your boxes.
NOTE 2: You will have to kill all the jobs that are left running after quitting the activate-followers function. You may want to do this manually as the function provided does a brute force kill on ALL backgrounded jobs
NOTE 3: This assumes a working unix-like environment, which you can get by installing cygwin
Who says you can't do lisp in shellscript ;-)
You can checkout in'side log.
A Java tool I created, able to read local and distant log files using SSH. It is fairly simple to use.
Some more explanations: https://github.com/pschweitz/insidelog/wiki
Just download the version corresponding to your operating system, or the native jar release executable within your Java Runtime (requires java 8_40 or higher):
https://github.com/pschweitz/insidelog/releases
You can find a complete documentation (embedded with and in Github's page as well)
Two options that pop into my mind first.
Choose your favorite SSH app (putty, ssh in cygwin, etc) and log into the machine.
1. SSH for each log (lots of windows open on your machine or tabs depending on your app)
2. SSH once and use screen.
If you actually needed to see both logs at the same time, and tabs were out of the question, you could install a perl script called LogResolveMerge.pl. It'll will merge two logs together, and dump the output to STDOUT. However, it will be resource intensive, and if your intention is to tail -f the logs, it likely won't be too effective.