[syslog-ng] Python external program destination and line buffer

Balint Kovacs balint.kovacs at balabit.com
Thu Oct 22 00:04:30 CEST 2015


Hi Giovanni,

the python fileinput module does have a read buffer, that is very handy
under heavy load, but for testing you might be better off with
sys.stdin.readline()

Best regards,
Balint

On 10/21/2015 07:54 PM, Giovanni Mancuso wrote:
> Hi,
> i wrote a program destination (in python) that parse a message and
> insert data in redis.
>
> My code is:
> import re
> import fileinput
> import redis
>
> r = redis.Redis(host="127.0.0.1", port=6379, db=0)
>
> for line in fileinput.input():
>     tid = re.search('X-TransactionId: (.+?) ', line)
>     #print tid.group(1)
>     regexp_result = re.findall(" Recipient:
> ([A-z0-9._%+-]+@[A-z0-9.-]+)", line)
>     for email in regexp_result:
>         r.sadd(tid.group(1)+"_recs", email)
>
> I configure my destination in this way:
> destination python_to_file {
>     program("/usr/bin/python /etc/syslog-ng/python/Ric_acc_dest.py"
> flush-lines(1));
> };
>
> It works only if i send many message. If i send only one message it
> doesn't insert nothing in redis.
>
> Any ideas?
>
>
>
> -- 
>
>
>
> ______________________________________________________________________________
> 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
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.balabit.hu/pipermail/syslog-ng/attachments/20151022/e5033471/attachment-0001.htm 


More information about the syslog-ng mailing list