summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--plugins/ommongodb/Makefile.am4
-rw-r--r--plugins/ommongodb/ommongodb.c69
-rw-r--r--runtime/rsyslog.h1
4 files changed, 27 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac
index 0fe664a4..1d7aec58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1283,9 +1283,6 @@ if test "x$enable_ommongodb" = "xyes"; then
PKG_CHECK_MODULES(LIBMONGO_CLIENT, libmongo-client >= 0.1.4)
AC_SUBST(LIBMONGO_CLIENT_CFLAGS)
AC_SUBST(LIBMONGO_CLIENT_LIBS)
- PKG_CHECK_MODULES([JSON_C], [json])
- AC_SUBST([JSON_CFLAGS])
- AC_SUBST([JSON_LIBS])
fi
AM_CONDITIONAL(ENABLE_OMMONGODB, test x$enable_ommongodb = xyes)
# end of mongodb code
diff --git a/plugins/ommongodb/Makefile.am b/plugins/ommongodb/Makefile.am
index 8b13c254..3a05c435 100644
--- a/plugins/ommongodb/Makefile.am
+++ b/plugins/ommongodb/Makefile.am
@@ -1,7 +1,7 @@
pkglib_LTLIBRARIES = ommongodb.la
ommongodb_la_SOURCES = ommongodb.c
-ommongodb_la_CPPFLAGS = $(RSRT_CFLAGS) $(PTHREADS_CFLAGS) $(LIBMONGO_CLIENT_CFLAGS) $(JSON_C_CFLAGS)
+ommongodb_la_CPPFLAGS = $(RSRT_CFLAGS) $(PTHREADS_CFLAGS) $(LIBMONGO_CLIENT_CFLAGS)
ommongodb_la_LDFLAGS = -module -avoid-version
-ommongodb_la_LIBADD = $(LIBMONGO_CLIENT_LIBS) $(JSON_C_LIBS)
+ommongodb_la_LIBADD = $(LIBMONGO_CLIENT_LIBS)
EXTRA_DIST =
diff --git a/plugins/ommongodb/ommongodb.c b/plugins/ommongodb/ommongodb.c
index 9a7ca9f7..f2de33df 100644
--- a/plugins/ommongodb/ommongodb.c
+++ b/plugins/ommongodb/ommongodb.c
@@ -406,48 +406,6 @@ error:
return NULL;
}
-/* Return a BSON document based on user's JSON string. */
-static bson *
-BSONFromJSONString(instanceData *pData, const char *json_string)
-{
- size_t json_string_len;
- struct json_object *json;
- bson *doc = NULL;
- const char *error_message;
-
- json_tokener_reset(pData->json_tokener);
-
- json_string_len = strlen(json_string);
- json = json_tokener_parse_ex(pData->json_tokener,
- json_string, json_string_len);
- error_message = NULL;
- if(json == NULL) {
- enum json_tokener_error err;
-
- err = pData->json_tokener->err;
- if(err != json_tokener_continue)
- error_message = json_tokener_errors[err];
- else
- error_message = "Unterminated input";
- } else if((size_t)pData->json_tokener->char_offset < json_string_len)
- error_message = "Extra characters after JSON object";
- else if(!json_object_is_type(json, json_type_object))
- error_message = "JSON value is not an object";
- if(error_message != NULL) {
- /* FIXME: is dbgprintf() the correct way to report the error? */
- dbgprintf("ommongodb: Error parsing JSON '%s': %s\n",
- json_string, error_message);
- goto done;
- }
-
- doc = BSONFromJSONObject(json);
-
-done:
- if(json != NULL)
- json_object_put(json);
- return doc;
-}
-
BEGINtryResume
CODESTARTtryResume
if(pData->conn == NULL) {
@@ -466,7 +424,7 @@ CODESTARTdoAction
if(pData->tplName == NULL) {
doc = getDefaultBSON((msg_t*)ppString[0]);
} else {
- doc = BSONFromJSONString(pData, (const char *)ppString[0]);
+ doc = BSONFromJSONObject((struct json_object *)ppString[0]);
}
if(doc == NULL) {
dbgprintf("ommongodb: error creating BSON doc\n");
@@ -537,7 +495,7 @@ CODESTARTnewActInst
CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG));
} else {
CHKiRet(OMSRsetEntry(*ppOMSR, 0, ustrdup(pData->tplName),
- OMSR_NO_RQD_TPL_OPTS));
+ OMSR_TPL_AS_JSON));
CHKmalloc(pData->json_tokener = json_tokener_new());
}
@@ -590,6 +548,10 @@ CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
ENDqueryEtryPt
BEGINmodInit()
+ rsRetVal localRet;
+ rsRetVal (*pomsrGetSupportedTplOpts)(unsigned long *pOpts);
+ unsigned long opts;
+ int bJSONPassingSupported;
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
@@ -597,5 +559,22 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(datetime, CORE_COMPONENT));
INITChkCoreFeature(bCoreSupportsBatching, CORE_FEATURE_BATCHING);
DBGPRINTF("ommongodb: module compiled with rsyslog version %s.\n", VERSION);
- //DBGPRINTF("ommongodb: %susing transactional output interface.\n", bCoreSupportsBatching ? "" : "not ");
+
+ /* check if the rsyslog core supports parameter passing code */
+ bJSONPassingSupported = 0;
+ localRet = pHostQueryEtryPt((uchar*)"OMSRgetSupportedTplOpts",
+ &pomsrGetSupportedTplOpts);
+ if(localRet == RS_RET_OK) {
+ /* found entry point, so let's see if core supports msg passing */
+ CHKiRet((*pomsrGetSupportedTplOpts)(&opts));
+ if(opts & OMSR_TPL_AS_JSON)
+ bJSONPassingSupported = 1;
+ } else if(localRet != RS_RET_ENTRY_POINT_NOT_FOUND) {
+ ABORT_FINALIZE(localRet); /* Something else went wrong, not acceptable */
+ }
+ if(!bJSONPassingSupported) {
+ DBGPRINTF("ommongodb: JSON-passing is not supported by rsyslog core, "
+ "can not continue.\n");
+ ABORT_FINALIZE(RS_RET_NO_JSON_PASSING);
+ }
ENDmodInit
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 57e8a05c..928c3ab9 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -380,6 +380,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_DUP_PARAM = -2220, /**< config parameter is given more than once */
RS_RET_MODULE_ALREADY_IN_CONF = -2221, /**< module already in current configuration */
RS_RET_PARAM_NOT_PERMITTED = -2222, /**< legacy parameter no longer permitted (usally already set by v2) */
+ RS_RET_NO_JSON_PASSING = -2223, /**< rsyslog core does not support JSON-passing plugin API */
/* RainerScript error messages (range 1000.. 1999) */
RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */