views:

1512

answers:

6

hi there,

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

+1  A: 

You could use Putty Connection Manager to add tabs to PuTTy. Then SSH into the machine twice and tab back and forth.

Tutorial on Setting it Up

Owen
+3  A: 

You could just ssh to one server, and use mutitail from there to tail the logs on all the other servers.

zigdon
sounds like it is useful except I am not supposed to install any software on the linux/solaris servers.
anjanb
multitail will work over ssh. multitail -l 'ssh host tail -f file1' -l 'ssh host tail -f file2
Schwern
A: 

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.

dwj
thank you.sounds like it is useful except I am not supposed to install any software on the linux/solaris servers. I need a solution from my windows XP box.
anjanb
+1  A: 

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.

zigdon
thank you.sounds like it is useful except I am not supposed to install any software on the linux/solaris servers. I need a solution from my windows XP box.
anjanb
A: 

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.

f4nt
thank you for the perl script. I can use it in an alternate scenario.
anjanb
+1  A: 

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 ;-)

dsm