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

Giovanni Mancuso giovanni.mancuso at par-tec.it
Wed Oct 21 19:54:57 CEST 2015


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?



-- 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.balabit.hu/pipermail/syslog-ng/attachments/20151021/59732b9c/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: giovanni_mancuso.vcf
Type: text/x-vcard
Size: 319 bytes
Desc: not available
Url : http://lists.balabit.hu/pipermail/syslog-ng/attachments/20151021/59732b9c/attachment.vcf 


More information about the syslog-ng mailing list