[syslog-ng] Is it possible to include a external python script?

Scheidler, Bal√°zs balazs.scheidler at balabit.com
Mon Mar 20 05:35:36 UTC 2017


The example Python code should be unindented, or you see a different error?

Also, you can always import code in the python block.

With destinations you can specify a path to a python file, so the python
block is not needed. But with template functions I've figured the $(python)
call would be too crowded if we were passing explicit filename parameters.

But you can encapsulate the python code as well as a wrapper to the python
code into a separate file.


python {

from foobar import foobar_template_function


template-function foobar "$(python foobar)"


Then you can use:

@include "Foobar.conf"


Unfortunately then template function declarations cant take parameters yet
from the callsite, which may be a serious limitation in your use-case. But
with a conceot above you can completely hide implementation details your
actual config.

On Mar 20, 2017 03:53, "Jorge Pereira" <jpereiran at gmail.com> wrote:

> Well, based on this[1] document. We should use the *python {}* statement.
> But, I would like to keep my python script externally in a separated file
> and do something like.
> python filter_001 {
>    /my/script/python001.py
> }
> log {
>    ....
>    filter(filter_001);
>    ....
> };
> p.s: Btw, this sample https://www.balabit.com/documents/syslog-ng-ose-3.
> 7-guides/en/syslog-ng-ose-guide-admin/html-single/index.
> html#example-python-template-functions don't work in the syslog-ng 3.9.1
> [1] https://www.balabit.com/sites/default/files/documents/syslog
> -ng-ose-3.7-guides/en/syslog-ng-ose-v3.7-guide-admin/html-
> single/index.html#example-python-template-functions
> --
> Jorge Pereira
> ____________________________________________________________
> __________________
> 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/20170320/54b8da72/attachment.html>

More information about the syslog-ng mailing list