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