<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Giovanni,<br>
<br>
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()<br>
<br>
Best regards,<br>
Balint<br>
<br>
On 10/21/2015 07:54 PM, Giovanni Mancuso wrote:<br>
</div>
<blockquote cite="mid:5627D171.4020700@par-tec.it" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
Hi, <br>
i wrote a program destination (in python) that parse a message and
insert data in redis.<br>
<br>
My code is:<br>
<small>import re<br>
import fileinput<br>
import redis<br>
<br>
r = redis.Redis(host="127.0.0.1", port=6379, db=0)<br>
<br>
for line in fileinput.input():<br>
tid = re.search('X-TransactionId: (.+?) ', line)<br>
#print tid.group(1)<br>
regexp_result = re.findall(" Recipient:
([A-z0-9._%+-]+@[A-z0-9.-]+)", line)<br>
for email in regexp_result:<br>
r.sadd(tid.group(1)+"_recs", email)</small><br>
<br>
I configure my destination in this way:<br>
<small>destination python_to_file {<br>
program("/usr/bin/python
/etc/syslog-ng/python/Ric_acc_dest.py" flush-lines(1));<br>
};</small><br>
<br>
It works only if i send many message. If i send only one message
it doesn't insert nothing in redis.<br>
<br>
Any ideas?<br>
<br>
<br>
<br>
<div class="moz-signature">-- <br>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">______________________________________________________________________________
Member info: <a class="moz-txt-link-freetext" href="https://lists.balabit.hu/mailman/listinfo/syslog-ng">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a>
Documentation: <a class="moz-txt-link-freetext" href="http://www.balabit.com/support/documentation/?product=syslog-ng">http://www.balabit.com/support/documentation/?product=syslog-ng</a>
FAQ: <a class="moz-txt-link-freetext" href="http://www.balabit.com/wiki/syslog-ng-faq">http://www.balabit.com/wiki/syslog-ng-faq</a>
</pre>
</blockquote>
<br>
</body>
</html>