<div dir="ltr"><div>Thanks a lot, will see that I can merge asap. In order to be useful, there would need to be at least some minimal doc (so that users at least know this module exists). Would you mind adding a basic doc page for the module? You could use e.g. ./doc/omsnmp as an example.<br>
<br></div>Thanks,<br>Rainer<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 24, 2013 at 9:45 PM, Yannick Brosseau <span dir="ltr"><<a href="mailto:yannick.brosseau@gmail.com" target="_blank">yannick.brosseau@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This module will call a LTTng-UST tracepoint with each syslog entry.<br>
When LTTng is activated, this will write the entries in a CTF<br>
(Common Trace Format) file. This allow the correlating of other trace<br>
sources (kernel traces, other userspace traces) with system events<br>
logged with the syslog deamon.<br>
<br>
3 differents tracepoints are available (msg_string, msg_detailled and<br>
msg_detailled_time) and they are selected with the boolean<br>
configuration variables actionomlttngustmsgdetailled and<br>
actionomlttngustlogsyslogtime. The msg_detailled is the default one.<br>
<br>
An option to enable its compilation was added to the configure script<br>
(--enable-omlttngust)<br>
<br>
Once you load the module, you can activate the tracing with<br>
the lttng command line tool.<br>
<br>
Signed-off-by: Yannick Brosseau <<a href="mailto:yannick.brosseau@gmail.com">yannick.brosseau@gmail.com</a>><br>
---<br>
 Makefile.am                             |   4 +<br>
 <a href="http://configure.ac" target="_blank">configure.ac</a>                            |  20 +++<br>
 plugins/omlttngust/Makefile.am          |   8 ++<br>
 plugins/omlttngust/omlttngust.c         | 244 ++++++++++++++++++++++++++++++++<br>
 plugins/omlttngust/rsyslog-tracepoint.h |  79 +++++++++++<br>
 5 files changed, 355 insertions(+)<br>
 create mode 100644 plugins/omlttngust/Makefile.am<br>
 create mode 100644 plugins/omlttngust/omlttngust.c<br>
 create mode 100644 plugins/omlttngust/rsyslog-tracepoint.h<br>
<br>
diff --git a/Makefile.am b/Makefile.am<br>
index c5e41c7..341e2b8 100644<br>
--- a/Makefile.am<br>
+++ b/Makefile.am<br>
@@ -265,6 +265,10 @@ if ENABLE_ORACLE<br>
 SUBDIRS += plugins/omoracle<br>
 endif<br>
<br>
+if ENABLE_OMLTTNGUST<br>
+SUBDIRS += plugins/omlttngust<br>
+endif<br>
+<br>
 if ENABLE_GUI<br>
 SUBDIRS += java<br>
 endif<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 2f23147..cd94b3e 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -1425,6 +1425,24 @@ fi<br>
 AM_CONDITIONAL(ENABLE_OMMONGODB, test x$enable_ommongodb = xyes)<br>
 # end of mongodb code<br>
<br>
+<br>
+#LTTng-ust output SUPPORT<br>
+<br>
+AC_ARG_ENABLE(omlttngust,<br>
+        [AS_HELP_STRING([--enable-omlttngust],[Compiles omlttngust template module @<:@default=no@:>@])],<br>
+        [case "${enableval}" in<br>
+         yes) enable_omlttngust="yes" ;;<br>
+          no) enable_omlttngust="no" ;;<br>
+           *) AC_MSG_ERROR(bad value ${enableval} for --enable-omlttngust) ;;<br>
+         esac],<br>
+        [enable_omlttngust=no]<br>
+)<br>
+if test "x$enable_omlttngust" = "xyes"; then<br>
+       PKG_CHECK_MODULES(LIBLTTNG_UST, lttng-ust >= 2.0)<br>
+fi<br>
+AM_CONDITIONAL(ENABLE_OMLTTNGUST, test x$enable_omlttngust = xyes)<br>
+# end of lttng-ust code<br>
+<br>
 # BEGIN ZMQ3 INPUT SUPPORT<br>
 AC_ARG_ENABLE(imzmq3,<br>
         [AS_HELP_STRING([--enable-imzmq3],[Compiles imzmq3 output module @<:@default=no@:>@])],<br>
@@ -1558,6 +1576,7 @@ AC_CONFIG_FILES([Makefile \<br>
                plugins/omelasticsearch/Makefile \<br>
                plugins/sm_cust_bindcdr/Makefile \<br>
                plugins/mmsnmptrapd/Makefile \<br>
+               plugins/omlttngust/Makefile \<br>
                java/Makefile \<br>
                tests/Makefile])<br>
 AC_OUTPUT<br>
@@ -1605,6 +1624,7 @@ echo "    omudpspoof module will be compiled:       $enable_omudpspoof"<br>
 echo "    omuxsock module will be compiled:         $enable_omuxsock"<br>
 echo "    omzmq3 module will be compiled:           $enable_omzmq3"<br>
 echo "    omrabbitmq module will be compiled:       $enable_omrabbitmq"<br>
+echo "    omlttngust module will be compiled:       $enable_omlttngust"<br>
 echo<br>
 echo "---{ parser modules }---"<br>
 echo "    pmrfc3164sd module will be compiled:      $enable_pmrfc3164sd"<br>
diff --git a/plugins/omlttngust/Makefile.am b/plugins/omlttngust/Makefile.am<br>
new file mode 100644<br>
index 0000000..8a2f2c3<br>
--- /dev/null<br>
+++ b/plugins/omlttngust/Makefile.am<br>
@@ -0,0 +1,8 @@<br>
+pkglib_LTLIBRARIES = <a href="http://omlttngust.la" target="_blank">omlttngust.la</a><br>
+<br>
+omlttngust_la_SOURCES = omlttngust.c<br>
+omlttngust_la_CPPFLAGS =  $(RSRT_CFLAGS) $(PTHREADS_CFLAGS) $(LIBLTTNG_UST_CFLAGS)<br>
+omlttngust_la_LDFLAGS = -module -avoid-version<br>
+omlttngust_la_LIBADD =  $(LIBLTTNG_UST_LIBS)<br>
+<br>
+EXTRA_DIST =<br>
diff --git a/plugins/omlttngust/omlttngust.c b/plugins/omlttngust/omlttngust.c<br>
new file mode 100644<br>
index 0000000..cb4639f<br>
--- /dev/null<br>
+++ b/plugins/omlttngust/omlttngust.c<br>
@@ -0,0 +1,244 @@<br>
+/* omlttngust.c<br>
+ * send all output to an LTTng-UST tracepoint<br>
+ *<br>
+ * Copyright 2013 Yannick Brosseau<br>
+ *<br>
+ * This file is part of rsyslog.<br>
+ *<br>
+ * Licensed under the Apache License, Version 2.0 (the "License");<br>
+ * you may not use this file except in compliance with the License.<br>
+ * You may obtain a copy of the License at<br>
+ *<br>
+ *       <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a><br>
+ *       -or-<br>
+ *       see COPYING.ASL20 in the source distribution<br>
+ *<br>
+ * Unless required by applicable law or agreed to in writing, software<br>
+ * distributed under the License is distributed on an "AS IS" BASIS,<br>
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>
+ * See the License for the specific language governing permissions and<br>
+ * limitations under the License.<br>
+ */<br>
+#include "config.h"<br>
+#include "rsyslog.h"<br>
+#include <stdio.h><br>
+#include <stdarg.h><br>
+#include <stdlib.h><br>
+#include <string.h><br>
+#include <assert.h><br>
+#include <signal.h><br>
+#include <errno.h><br>
+#include <unistd.h><br>
+#include "conf.h"<br>
+#include "syslogd-types.h"<br>
+#include "srUtils.h"<br>
+#include "template.h"<br>
+#include "module-template.h"<br>
+#include "errmsg.h"<br>
+#include "cfsysline.h"<br>
+<br>
+#include <lttng/ust.h><br>
+<br>
+#define TRACEPOINT_DEFINE<br>
+#define TRACEPOINT_CREATE_PROBES<br>
+/*<br>
+ * The header containing our TRACEPOINT_EVENTs.<br>
+ */<br>
+<br>
+#include "rsyslog-tracepoint.h"<br>
+<br>
+MODULE_TYPE_OUTPUT<br>
+MODULE_TYPE_NOKEEP<br>
+MODULE_CNFNAME("omlttngust")<br>
+<br>
+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal);<br>
+<br>
+/* internal structures<br>
+ */<br>
+DEF_OMOD_STATIC_DATA<br>
+<br>
+/* config variables */<br>
+<br>
+<br>
+typedef struct _instanceData {<br>
+       int bUseMsgInterface; /* 1 - Use the msg interface and write to detailled tracepoint 0 - Write the whole entry as a string */<br>
+       int bLogSyslogTime; /* 1 - With the detailled tracepoint, write a time string with the syslog timestamp */<br>
+} instanceData;<br>
+<br>
+typedef struct configSettings_s {<br>
+       int bUseMsgInterface;<br>
+       int bLogSyslogTime;<br>
+} configSettings_t;<br>
+static configSettings_t cs;<br>
+<br>
+BEGINinitConfVars              /* (re)set config variables to default values */<br>
+CODESTARTinitConfVars<br>
+       resetConfigVariables(NULL, NULL);<br>
+ENDinitConfVars<br>
+<br>
+BEGINcreateInstance<br>
+CODESTARTcreateInstance<br>
+ENDcreateInstance<br>
+<br>
+<br>
+BEGINisCompatibleWithFeature<br>
+CODESTARTisCompatibleWithFeature<br>
+       if(eFeat == sFEATURERepeatedMsgReduction)<br>
+               iRet = RS_RET_OK;<br>
+ENDisCompatibleWithFeature<br>
+<br>
+<br>
+BEGINfreeInstance<br>
+CODESTARTfreeInstance<br>
+ENDfreeInstance<br>
+<br>
+<br>
+BEGINdbgPrintInstInfo<br>
+CODESTARTdbgPrintInstInfo<br>
+ENDdbgPrintInstInfo<br>
+<br>
+<br>
+BEGINtryResume<br>
+CODESTARTtryResume<br>
+ENDtryResume<br>
+<br>
+static int<br>
+processMsg(msg_t *pMsg, int bWantTimestampField)<br>
+{<br>
+       uchar *msg; short unsigned msg_free; rs_size_t msg_len;<br>
+       uchar *procid; short unsigned procid_free; rs_size_t procid_len;<br>
+       int severity, facil;<br>
+       uchar *hostname; short unsigned sys_free; rs_size_t sys_len;<br>
+       uchar *timestamp; short unsigned timestamp_free; rs_size_t timestamp_len;<br>
+       uchar *time_gen; short unsigned time_gen_free; rs_size_t time_gen_len;<br>
+       uchar *pid; short unsigned pid_free; rs_size_t pid_len;<br>
+<br>
+       msg = MsgGetProp(pMsg, NULL, PROP_MSG, NULL, &msg_len, &msg_free, NULL);<br>
+       procid = MsgGetProp(pMsg, NULL, PROP_PROGRAMNAME, NULL, &procid_len, &procid_free, NULL);<br>
+       hostname = MsgGetProp(pMsg, NULL, PROP_HOSTNAME, NULL, &sys_len, &sys_free, NULL);<br>
+<br>
+       pid = MsgGetProp(pMsg, NULL, PROP_PROCID, NULL, &pid_len, &pid_free, NULL);<br>
+<br>
+       severity = pMsg->iSeverity;<br>
+       facil = pMsg->iFacility;<br>
+<br>
+       if(bWantTimestampField) {<br>
+               /* TODO Set a template format to get the miliseconds? */<br>
+               timestamp = MsgGetProp(pMsg, NULL, PROP_TIMESTAMP, NULL, &timestamp_len, &timestamp_free, NULL);<br>
+<br>
+               time_gen = MsgGetProp(pMsg, NULL, PROP_TIMEGENERATED, NULL, &time_gen_len, &time_gen_free, NULL);<br>
+<br>
+               tracepoint(rsyslog, msg_detailled_time, (char *) msg, severity, facil, hostname, procid, pid, timestamp, time_gen);<br>
+       } else {<br>
+               tracepoint(rsyslog, msg_detailled, (char *) msg, severity, facil, hostname, procid, pid);<br>
+       }<br>
+<br>
+<br>
+       return 0;<br>
+}<br>
+BEGINdoAction<br>
+       char *toWrite;<br>
+CODESTARTdoAction<br>
+<br>
+<br>
+        if(pData->bUseMsgInterface) {<br>
+               processMsg((msg_t*)ppString[0], pData->bLogSyslogTime);<br>
+       } else {<br>
+               /* Use the simple formated string when msg parsing is not used */<br>
+               toWrite = (char*) ppString[0];<br>
+<br>
+               tracepoint(rsyslog, msg_string, toWrite);<br>
+<br>
+       }<br>
+ENDdoAction<br>
+<br>
+<br>
+BEGINparseSelectorAct<br>
+       int iTplOpts;<br>
+CODESTARTparseSelectorAct<br>
+CODE_STD_STRING_REQUESTparseSelectorAct(1)<br>
+       /* first check if this config line is actually for us */<br>
+       if(strncmp((char*) p, ":omlttngust:", sizeof(":omlttngust:") - 1)) {<br>
+               ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED);<br>
+       }<br>
+<br>
+       /* ok, if we reach this point, we have something for us */<br>
+       p += sizeof(":omlttngust:") - 1; /* eat indicator sequence  (-1 because of '\0'!) */<br>
+       CHKiRet(createInstance(&pData));<br>
+<br>
+       /* check if a non-standard template is to be applied */<br>
+       if(*(p-1) == ';')<br>
+               --p;<br>
+       iTplOpts = (cs.bUseMsgInterface == 0) ? 0 : OMSR_TPL_AS_MSG ;<br>
+<br>
+       CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, iTplOpts, (uchar*) "RSYSLOG_FileFormat"));<br>
+       pData->bUseMsgInterface = cs.bUseMsgInterface;<br>
+        pData->bLogSyslogTime = cs.bLogSyslogTime;<br>
+CODE_STD_FINALIZERparseSelectorAct<br>
+ENDparseSelectorAct<br>
+<br>
+<br>
+BEGINmodExit<br>
+CODESTARTmodExit<br>
+ENDmodExit<br>
+<br>
+<br>
+BEGINqueryEtryPt<br>
+CODESTARTqueryEtryPt<br>
+CODEqueryEtryPt_STD_OMOD_QUERIES<br>
+CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES<br>
+ENDqueryEtryPt<br>
+<br>
+<br>
+<br>
+/* Reset config variables for this module to default values.<br>
+ */<br>
+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)<br>
+{<br>
+       DEFiRet;<br>
+       cs.bUseMsgInterface = 1;<br>
+       cs.bLogSyslogTime = 0;<br>
+       RETiRet;<br>
+}<br>
+<br>
+<br>
+BEGINmodInit()<br>
+       rsRetVal localRet;<br>
+       rsRetVal (*pomsrGetSupportedTplOpts)(unsigned long *pOpts);<br>
+       unsigned long opts;<br>
+       int bMsgPassingSupported;<br>
+CODESTARTmodInit<br>
+INITLegCnfVars<br>
+       *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */<br>
+CODEmodInit_QueryRegCFSLineHdlr<br>
+<br>
+       /* check if the rsyslog core supports parameter passing code */<br>
+        bMsgPassingSupported = 0;<br>
+       localRet = pHostQueryEtryPt((uchar*)"OMSRgetSupportedTplOpts", &pomsrGetSupportedTplOpts);<br>
+       if(localRet == RS_RET_OK) {<br>
+               /* found entry point, so let's see if core supports array passing */<br>
+               CHKiRet((*pomsrGetSupportedTplOpts)(&opts));<br>
+               if(opts & OMSR_TPL_AS_MSG)<br>
+                       bMsgPassingSupported = 1;<br>
+       } else if(localRet != RS_RET_ENTRY_POINT_NOT_FOUND) {<br>
+               ABORT_FINALIZE(localRet); /* Something else went wrong, what is not acceptable */<br>
+       }<br>
+       DBGPRINTF("omlttngust: msg-passing is %ssupported by rsyslog core.\n", bMsgPassingSupported ? "" : "not ");<br>
+<br>
+       if(bMsgPassingSupported) {<br>
+               /* enable config command only if core supports msg passing */<br>
+               CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionomlttngustmsgdetailled", 0, eCmdHdlrBinary, NULL,<br>
+                                          &cs.bUseMsgInterface, STD_LOADABLE_MODULE_ID));<br>
+<br>
+<br>
+               CHKiRet(omsdRegCFSLineHdlr((uchar *)"actionomlttngustlogsyslogtime", 0, eCmdHdlrBinary, NULL,<br>
+                                          &cs.bLogSyslogTime, STD_LOADABLE_MODULE_ID));<br>
+       }<br>
+<br>
+       CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,<br>
+                                   resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));<br>
+<br>
+ENDmodInit<br>
+<br>
+/* vi:set ai:<br>
+ */<br>
diff --git a/plugins/omlttngust/rsyslog-tracepoint.h b/plugins/omlttngust/rsyslog-tracepoint.h<br>
new file mode 100644<br>
index 0000000..037364b<br>
--- /dev/null<br>
+++ b/plugins/omlttngust/rsyslog-tracepoint.h<br>
@@ -0,0 +1,79 @@<br>
+<br>
+#undef TRACEPOINT_PROVIDER<br>
+#define TRACEPOINT_PROVIDER rsyslog<br>
+<br>
+#undef TRACEPOINT_INCLUDE<br>
+#define TRACEPOINT_INCLUDE "./rsyslog-tracepoint.h"<br>
+<br>
+<br>
+#ifdef __cplusplus<br>
+extern "C"{<br>
+#endif /* __cplusplus */<br>
+<br>
+<br>
+#if !defined(RSYSLOG_H) || defined(TRACEPOINT_HEADER_MULTI_READ)<br>
+#define RSYSLOG_H<br>
+<br>
+#include <lttng/tracepoint.h><br>
+<br>
+TRACEPOINT_EVENT(<br>
+       rsyslog,<br>
+       msg_string,<br>
+       TP_ARGS(char *, text),<br>
+       TP_FIELDS(<br>
+               ctf_string(message, text)<br>
+                 )<br>
+)<br>
+<br>
+TRACEPOINT_EVENT(<br>
+       rsyslog,<br>
+       msg_detailled,<br>
+       TP_ARGS(char *, text, int, severity, int, facility, uchar*, hostname, uchar*, progname, uchar *, pid ),<br>
+       TP_FIELDS(<br>
+               ctf_string(message, text)<br>
+               ctf_integer(int, severity, severity)<br>
+               ctf_integer(int, facility, facility)<br>
+               ctf_string(hostname, hostname)<br>
+               ctf_string(progname, progname)<br>
+               ctf_string(pid, pid)<br>
+                 )<br>
+)<br>
+<br>
+TRACEPOINT_EVENT(<br>
+       rsyslog,<br>
+       msg_detailled_time,<br>
+       TP_ARGS(char *, text, int, severity, int, facility, uchar*, hostname, uchar*, progname,  uchar *, pid, uchar *, time, uchar*, time_gen),<br>
+       TP_FIELDS(<br>
+               ctf_string(message, text)<br>
+               ctf_integer(int, severity, severity)<br>
+               ctf_integer(int, facility, facility)<br>
+               ctf_string(hostname, hostname)<br>
+               ctf_string(progname, progname)<br>
+               ctf_string(pid, pid)<br>
+               ctf_string(time_str, time)<br>
+               ctf_string(time_gen_str, time_gen)<br>
+                 )<br>
+)<br>
+<br>
+TRACEPOINT_EVENT(<br>
+                rsyslog,<br>
+                init,<br>
+                TP_ARGS(),<br>
+                TP_FIELDS()<br>
+                )<br>
+<br>
+TRACEPOINT_EVENT(<br>
+                rsyslog,<br>
+                config,<br>
+                TP_ARGS(),<br>
+                TP_FIELDS()<br>
+                )<br>
+<br>
+#endif /* RSYSLOG_H */<br>
+<br>
+#include <lttng/tracepoint-event.h><br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif /* __cplusplus */<br>
+<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.4.rc3<br>
<br>
_______________________________________________<br>
rsyslog mailing list<br>
<a href="http://lists.adiscon.net/mailman/listinfo/rsyslog" target="_blank">http://lists.adiscon.net/mailman/listinfo/rsyslog</a><br>
<a href="http://www.rsyslog.com/professional-services/" target="_blank">http://www.rsyslog.com/professional-services/</a><br>
What's up with rsyslog? Follow <a href="https://twitter.com/rgerhards" target="_blank">https://twitter.com/rgerhards</a><br>
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.<br>
</font></span></blockquote></div><br></div>