Q: syslog-ng perl pipe dropping events I'm trying to pipe syslogs to a perl script via syslog-ng but not all of the syslog entries make it through - maybe 1 in 3 actually happen.
I've looked all over the place and can't find anyone remotely having the problem that I have. It seems so simple but I can't find the answer!
Here's my syslog-ng setup:
source s_1 { tcp(port(514)); };

destination d_zen { program("/tmp/zen.pl"); }; 

log { source(s_1); destination(d_zen); }; 

and here's my perl script:
#!/usr/bin/perl

use strict;
use warnings;

$|=1

my $filename = "/tmp/zen.log";
open(my $fh, '>>', $filename) or die "could not open file '$filename' $!";

while ( <STDIN> ) {

    print $fh <STDIN>."\n";

};

any thoughts?

A: Is your Perl line buffer disabled?
According to the syslog-ng manual, it can cause some problems:
"Certain external applications buffer the log messages, which might cause unexpected latency and other problems. For example, if you send the log messages to an external Perl script, Perl uses a line buffer for terminal output and block buffer otherwise. You might want to disable buffering in the external application."
Also, I don't know how your script reads the incoming messages (I don't now perl), but I think it should use a loop to keep reading incoming messages.
So syslog-ng should start the script once at startup, and it should keep running and processing messages.
HTH, 
Regards, 
Robert Fekete

A: I figured out the problem. My while loop wasn't built properly:
#!/usr/bin/perl

$|=1;

use strict;
use warnings;

my $filename = "/tmp/zen.log";
open(my $fh, '>', $filename) or die "could not open file '$filename' $!";

my $my_string;

while( <> ) {
    $my_string .= $_;
    print $fh "$my_string\n";
};

