Is it possible to create Two instances of syslog-ng engine ?
Hi, I have installed syslog-ng on my Linux box and I am planning you use syslog-ng parser and wanted to initialise it's engine for parsing the data. so initialise() method in my Go code calls C code that is wrapper around syslog-ng C header files. So ,I am making use of cgo. Following is my Go code: func (obj Syslogparser) initialise{ X := C.CString(obj.X) defer C.free(unsafe.Pointer(X)) Y := C.CString(obj.Y) defer C.free(unsafe.Pointer(Y)) C.initialize_engine(X, Y, (C.key_value_cb)(unsafe.Pointer(C.callOnMeGo_cgo))); } And following is my C method 'initialize_engine': int initialize_engine(const gchar* X, const gchar* Y, key_value_cb cb) // cb is callback function { module_path = _module_path; app_startup(); msg_init(TRUE); configuration = cfg_new(0x0302); plugin_load_module("basicfuncs", configuration, NULL); plugin_load_module("syslogformat", configuration, NULL); pattern_db_global_init(); if(patterndb != NULL){ pattern_db_free(patterndb); } patterndb = pattern_db_new(); pattern_db_reload_ruleset(patterndb, configuration, filename); pattern_db_set_emit_func(patterndb, pdbtool_pdb_emit_accumulate, cb); return 0; } My queries: 1)What is pattern_db_global_init, 'patterndb = pattern_db_new()', 'pattern_db_reload_ruleset', 'pattern_db_set_emit_func' doing in the following case ? 2)Can I make two independent instances of syslog-ng engines? 3)How can I call two instances of syslog-ng engines independently from my Go code? Thanks
Hi, Can someone please provide some info on this? Thankyou On Fri, May 10, 2019 at 12:55 PM Nitish Saboo <nitish.saboo55@gmail.com> wrote:
Hi,
I have installed syslog-ng on my Linux box and I am planning you use syslog-ng parser and wanted to initialise it's engine for parsing the data.
so initialise() method in my Go code calls C code that is wrapper around syslog-ng C header files. So ,I am making use of cgo.
Following is my Go code:
func (obj Syslogparser) initialise{
X := C.CString(obj.X) defer C.free(unsafe.Pointer(X)) Y := C.CString(obj.Y) defer C.free(unsafe.Pointer(Y)) C.initialize_engine(X, Y, (C.key_value_cb)(unsafe.Pointer(C.callOnMeGo_cgo))); }
And following is my C method 'initialize_engine':
int initialize_engine(const gchar* X, const gchar* Y, key_value_cb cb) // cb is callback function { module_path = _module_path; app_startup(); msg_init(TRUE);
configuration = cfg_new(0x0302); plugin_load_module("basicfuncs", configuration, NULL); plugin_load_module("syslogformat", configuration, NULL);
pattern_db_global_init();
if(patterndb != NULL){ pattern_db_free(patterndb); } patterndb = pattern_db_new(); pattern_db_reload_ruleset(patterndb, configuration, filename); pattern_db_set_emit_func(patterndb, pdbtool_pdb_emit_accumulate, cb);
return 0; }
My queries:
1)What is pattern_db_global_init, 'patterndb = pattern_db_new()', 'pattern_db_reload_ruleset', 'pattern_db_set_emit_func' doing in the following case ?
2)Can I make two independent instances of syslog-ng engines?
3)How can I call two instances of syslog-ng engines independently from my Go code?
Thanks
1)What is pattern_db_global_init, 'patterndb = pattern_db_new()', 'pattern_db_reload_ruleset', 'pattern_db_set_emit_func' doing in the following case ?
I am afraid there is no one can give you better understanding about these than yourself. Read the source, Luke! <https://blog.codinghorror.com/learn-to-read-the-source-luke/>
2)Can I make two independent instances of syslog-ng engines?
Engine can mean a lot of things. With much of oversimplification, here is my understanding of syslog-ng. The syslog-ng message handling is built around a directed (acyclic) graph, where the nodes are from class LogPipe. Pipes without incoming arcs are called sources. Pipes without outgoing arcs are the destinations. Other nodes might be filters or parsers. None of them can stand on their own. Some of them needs a worker thread in order to work, like sources and destinations. Filters and parsers do not own a worker thread, they are executed by some source thread they are connected to (determined by the graph). You can have any number of LogPipes in a single application. If you need worker threads, syslog-ng can provide them too: see mainloop.h, mainloop-worker.h. Single instance of MainLoop can provide you any number of worker threads. Or you can use your own eventloop solution.
3)How can I call two instances of syslog-ng engines independently from my Go code?
I am not familiar with go, but there must be some eventoop library for it. Or you can try to use MainLoop. Or if all fails, there must be a fork() system call exposed in go.
participants (2)
-
Nemes, Antal
-
Nitish Saboo