Not bad. We may just use this.

--
Puryear Information Technology, LLC
Baton Rouge, LA * 225-706-8414
http://www.puryear-it.com

Author:
   "Best Practices for Managing Linux and UNIX Servers"
   "Spam Fighting and Email Security in the 21st Century"

Download your free copies:
   http://www.puryear-it.com/publications.htm

Scott Harney wrote:
> -ray wrote:
>> I've used the logger command to log to syslog on the localhost.  Could you 
>> pipe the tailed file over ssh to a logger command on the syslog host? 
>> Just an idea :)
>>   
> I have a perl script that a coworker wrote that does a pretty good job 
> of handling a logrotate, you'd just have to add the system callout to 
> "logger"
> #!/usr/local/bin/perl
> 
> $USER = $ENV{'USER'};
> $LogToWatch = "/path/to/log";
> 
> FORK: {
>         if ( $PID = fork) {
>                 # PARENT HERE
>                 # Child process pid available in $PID
> 
>                 $COUNT = 0;
>                 $SIZE_ORIG =  (stat("$LogToWatch"))[7];
>                 while (true) {
>                         $SIZE = (stat("$LogToWatch"))[7];
>                                 ############### printf "SIZE: %s\n", $SIZE;
>                         if ($SIZE >= $SIZE_ORIG) {
>                                 sleep 5;
>                         } else {
>                                 `kill $PID`;
>                                 open(LOG,">> /path/to/othertemporary.log");
>                                         chomp($DATE = `date`);
>                                         printf LOG "$PID KILLED FOR 
> $USER $DATE\n";
>                                 close(LOG);
>                                 redo FORK;
>                         }
>                 }
>         } elsif ( defined $PID ) {
>                 # $PID is zero here if defined
>                 # Child here
>                 # parent process pid is available with getppid
>                 printf "HERE WE ARE RESTARTING THE 'TAIL'>>> \n";
>                 open(TAIL, "tail -100f $LogToWatch |") || die "Can't do 
> tail here. $!\n";
>                 while(<TAIL>) {
>                         print;
>                         #system ("logger -p daemon.info $_"); # might 
> work. untested.
>                 }
>                 exit;
>         } elsif ( $! =~ /No more process/ ) {
>                 # EAGAIN, supposedly recoverable fork error
>                 sleep 5;
>                 redo FORK;
>         } else {
>                 # weird fork error
>                 die "Can't do fork: $!\n";
>         }
> }
> 
>> ray
>>
>>
>> On Thu, 26 Apr 2007, Dustin Puryear wrote:
>>
>>   
>>> Is anyone aware of an existing tool that can tail a log file and direct
>>> the contents to a syslog host? If the tool can detect a log rotate that
>>> would be even better.
>>>
>>> Any ideas are welcome, thanks!
>>>
>>>
>>>     
>>
>>   
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> General mailing list
> General at brlug.net
> http://mail.brlug.net/mailman/listinfo/general_brlug.net

Reply via email to