<x-flowed>Everyone,
I noticed the logging thread on linux-router, and I remembered this
article in Linux Journal. Is this an acceptable solution?


Linux Journal June 2000 Issue 74 p.204
********************** Perl Script for Pull Logging **********************
#!/usr/bin/perl
$host="monitored.one";                  # host to log to
                                         # (machine to monitor)
$file="var/log/imp-logs";               # logging file on
                                         # remote machine
$login="wallace";                       # login name on remote machine
$ssh_opts="-q -C -o 'FallBackToRsh=no'";
                                         # options to  ssh
#$ssh_opts="-q +C";                     # better for ssh2
$cmd="tail --follow=name --retry";      # the tail command executed
#$cmd="tail --follow";                  # this could be
                                         # used with old tails
$local_log="pulllog-log";               # local log for
                                         # failures
sub open_remote {                       # open the connection
   open(SSH,"|ssh $ssh_opts -l $login $host
     ".'"'."$cmd $file".'"');"
   select(SSH);
   $|=1;                                 # make it unbuffered
}
if ($local_log) {                       # if local logging enabled
   open(LOG,">>$local_log");             # open log file
   select(LOG);
   $|+1;
}
select STDOUT;
$SIG{'PIPE'}='IGNORE';
open_remote();                          # try to establish the connection
while (1) {
   while (<SSH>) {
       print STDOUT;                     # print on our side
   }
   print LOG "remote end was dead at " .
     `date` if ($local_log);
   close(SSH);                           # if error occured
   open_remote();                        # try to open connection again
}

--
Mike Noyes <[EMAIL PROTECTED]>
http://leaf.sourceforge.net/


_______________________________________________
Leaf-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/leaf-devel
</x-flowed>

Reply via email to