0

I'm trying to use Syslog-ng so that it forwards the messages to a python destination. However, I keep getting a "Error parsing destination, destination plugin python not found ..." message.

I am following this tutorial exactly. https://syslog-ng.gitbooks.io/getting-started/content/chapters/chapter_5/section_1.html

From what I can gather, keywords "java" and "python" require Syslog-ng 3.7+. Which I have upgraded to from 3.5.6. I have also changed the provided config file @version: 3.7 to @version: 3.8 which is the only thing I changed from the example.

Any ideas why Syslog-ng doesn't recognize the keyword "python" in my config file?

Here is the script that was provided.

@version: 3.7
@include "scl.conf"

source s_local {
    system();
    internal();
};

destination python_to_file {
            python(
                class("betterpythonexample.TextDestination")
                on-error("fallback-to-string")
                value-pairs(scope(everything))
                );
                };

log {
    source(s_local);
    destination(python_to_file);
};   

This is the python code in the example.

    class LogDestination(object):

    def open(self):
        """Open a connection to the target service"""
        return True

    def close(self):
        """Close the connection to the target service"""
        pass

    def is_opened(self):
        """Check if the connection to the target is able to receive messages"""
        return True

    def init(self):
        """This method is called at initialization time"""
        return True

    def deinit(self):
        """This method is called at deinitialization time"""
        pass

    def send(self, msg):
        """Send a message to the target service

        It should return True to indicate success, False will suspend the
        destination for a period specified by the time-reopen() option."""
        pass


class TextDestination(LogDestination):
    def __init__(self):
        self.outfile = None

    def init(self):
        self.outfile = open('/tmp/example.txt', 'a')
        self.outfile.write("initialized\n")
        self.outfile.flush()
        return True

    def open(self):
        self.outfile.write("opened\n")
        self.outfile.flush()
        return True

    def close(self):
        self.outfile.write("closed\n")
        self.outfile.flush()
        return True

    def deinit(self):
        self.outfile.write("deinit\n")
        self.outfile.flush()
        self.outfile.close();
        return True

    def send(self, msg):
        self.outfile.write("Name Value Pairs are \n")

        for key,v in msg.items():
            self.outfile.write(str(key)+" "+str(v)+"\n");
        self.outfile.flush()
        return True

1 Answer 1

1

Check, if you have python support enabled using syslog-ng -V. mod-python should be listed among the available modules:

linux-utjy:~ # syslog-ng -V
syslog-ng 3.7.3
Installer-Version: 3.7.3
Revision: 
Available-Modules: afamqp,affile,afmongodb,afprog,afsocket,afstomp,afuser,basicfuncs,confgen,cryptofuncs,csvparser,dbparser,graphite,json-plugin,kvformat,linux-kmsg-format,pseudofile,sdjournal,syslogformat,system-source,mod-python
Enable-Debug: off
Enable-GProf: off
Enable-Memtrace: off
Enable-IPv6: on
Enable-Spoof-Source: on
Enable-TCP-Wrapper: on
Enable-Linux-Caps: off

If it is not, you should make sure, that you compile syslog-ng with python support or if you installed from packages, install a package called syslog-ng-python or similar.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .