[syslog-ng] Issue about using perl script in Receiving messages from external applications

Pal Tamas folti at balabit.hu
Fri Aug 10 10:31:54 CEST 2012


Hi,

IMO you should put the 2 lines before the while() block. You only have
to set it once.

On Fri, Aug 10, 2012 at 09:02:26AM +0800, Jian Zhu wrote:
> Thanks you Evan for you quick response. I changed my script as below and now
> it's working fine.
> 
> #!/usr/bin/perl
> 
> $i=0;
> while(true){
>         $i++;
>         #added below 2 lines to force a flush right away and after every print
>         #according to perl document: "STDOUT will typically be line buffered if
> output is to the terminal and block buffered otherwise."
>         #since the output is not to terminal so here it's block buffered, i
> guess this is the root cause.
>         select(STDOUT);
>         $| = 1;
> 
>         print STDOUT "hello $i\n";
> 
>         sleep 1;
> 
> }
> 
> 
> 
> 
> 
> On Fri, Aug 10, 2012 at 8:52 AM, Evan Rempel <erempel at uvic.ca> wrote:
> 
>     You are probably suffering from perl's buffering. I forget the exact syntax right now but a quick google of disabling Perl auto flush should give you what you need.
> 
>     Jian Zhu <zhujian0805 at gmail.com> wrote:
> 
> 
>     Hello,
> 
>     Could anyone please help me on this below issue?
> 
>     my syslog-ng.conf file look like below:
> 
>     The test.sh script work fine, I can see it's output in the test.sh.log
>     file.
>     But the test.pl doesn't work. the test.sh and test.pl have the same
>     function of printing something to STDOUT.
>     ------------------------------
>     -------------------------------------------------------------------------------------------------------------------
>     @version: 3.0
>     #Default configuration file for syslog-ng.
>     #
>     # For a description of syslog-ng configuration file directives, please read
>     # the syslog-ng Administrator s guide at:
>     #
>     # http://www.balabit.com/dl/html/syslog-ng-admin-guide_en.html/
>     bk01-toc.html
>     #
>     options {
>     # Number of syslog lines stored in memory before being written to files
>     flush_lines (0);
>     log_fifo_size (2048);
>     create_dirs (yes);
>     perm (0640);
>     dir_perm (0750);
>     };
> 
> 
> 
>     source ppp { program("/root/perl/test.pl"); };
>     destination ppp {
>     file ("/var/log/syslog-ng/$HOST/perl.pl.log" create_dirs(yes));
>     };
>     log {
>             source(ppp);
>             destination(ppp);
>     };
> 
>     source sss { program("/root/shell/test.sh"); };
>     destination sss {
>     file ("/var/log/syslog-ng/$HOST/test.sh.log" create_dirs(yes));
>     };
>     log {
>             source(sss);
>             destination(sss);
>     };
>     -------------------------------------------------------------------------------------------------------------------------------------------------
> 
> 
>     --
> 
>     Thanks & Best Regards
> 
>     James Zhu
> 
>     Mobile: +86 186 8482 2818
> 
>     Email: zhujian0805 at gmail.com
> 
> 
> 
>     ______________________________________________________________________________
>     Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng
>     Documentation: http://www.balabit.com/support/documentation/?product=
>     syslog-ng
>     FAQ: http://www.balabit.com/wiki/syslog-ng-faq
> 
> 
> 
> 
> 
> 
> --
> 
> Thanks & Best Regards
> 
> James Zhu
> 
> Mobile: +86 186 8482 2818
> 
> Email: zhujian0805 at gmail.com
> 
> 

> ______________________________________________________________________________
> Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng
> Documentation: http://www.balabit.com/support/documentation/?product=syslog-ng
> FAQ: http://www.balabit.com/wiki/syslog-ng-faq
> 


-- 
Pal Tamas/Folti
folti at balabit.hu



More information about the syslog-ng mailing list