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