summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-03-20 12:11:38 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-03-20 12:11:38 +0100
commite0d69d3e10bae3f108a58c12ca6a3ac3974827d0 (patch)
tree8cc39972c11ff41c44be7055fcc45599663010e5
parentbc29adfa8d3cb8f93eac5cf8b4c40a5d26aae154 (diff)
downloadrsyslog-e0d69d3e10bae3f108a58c12ca6a3ac3974827d0.tar.gz
rsyslog-e0d69d3e10bae3f108a58c12ca6a3ac3974827d0.tar.xz
rsyslog-e0d69d3e10bae3f108a58c12ca6a3ac3974827d0.zip
ommongodb: basic error reporting
-rw-r--r--plugins/ommongodb/README7
-rw-r--r--plugins/ommongodb/ommongodb.c24
2 files changed, 25 insertions, 6 deletions
diff --git a/plugins/ommongodb/README b/plugins/ommongodb/README
index 391dfcb9..71d56cfa 100644
--- a/plugins/ommongodb/README
+++ b/plugins/ommongodb/README
@@ -24,9 +24,10 @@ $ModLoad ommongodb # provides mongodb support
then in your /etc/rsyslog.d (check your distribution way to organize the configuration..) you create a file 10-mongodb.conf with the following content:
-#if you want to change what is logged in the db, the template, you must change the source code since the keys are hardcoded
-$template StdMongoDBFmt,"%programname%%HOSTNAME%%timestamp%%pri%%rawmsg%"
-*.* action(type="ommongodb" template="StdMongoDBFmt" db="..." collection="...")
+*.* action(type="ommongodb" db="..." collection="...")
+
+Note: currently templates are not supported. Ommongodb will pick a default
+schema and use the message object content for that (templateless).
TODO
diff --git a/plugins/ommongodb/ommongodb.c b/plugins/ommongodb/ommongodb.c
index a8429b1b..a247909d 100644
--- a/plugins/ommongodb/ommongodb.c
+++ b/plugins/ommongodb/ommongodb.c
@@ -123,6 +123,21 @@ CODESTARTdbgPrintInstInfo
ENDdbgPrintInstInfo
+/* report error that occured during *last* operation
+ */
+static void
+reportMongoError(instanceData *pData)
+{
+ gchar *err;
+ if(mongo_sync_cmd_get_last_error(pData->conn, (gchar*)pData->db, &err)) {
+ errmsg.LogError(0, RS_RET_ERR, "ommongodb: error: %s", err);
+ } else {
+ errmsg.LogError(0, RS_RET_ERR, "ommongodb: we had an error, but can "
+ "not obtain specifics");
+ }
+}
+
+
/* The following function is responsible for initializing a
* MySQL connection.
* Initially added 2004-10-28 mmeckelein
@@ -137,9 +152,10 @@ static rsRetVal initMongoDB(instanceData *pData, int bSilent)
pData->conn = mongo_sync_connect(server, pData->port, TRUE);
if(pData->conn == NULL) {
- if(!bSilent)
- errmsg.LogError(0, RS_RET_SUSPENDED,
- "can not initialize MongoDB handle");
+ if(!bSilent) {
+ reportMongoError(pData);
+ dbgprintf("ommongodb: can not initialize MongoDB handle");
+ }
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
@@ -212,11 +228,13 @@ rsRetVal writeMongoDB_msg(msg_t *pMsg, instanceData *pData)
if(doc == NULL) {
dbgprintf("ommongodb: error creating BSON doc\n");
+ reportMongoError(pData);
ABORT_FINALIZE(RS_RET_ERR);
}
bson_finish(doc);
if(!mongo_sync_cmd_insert(pData->conn, (char*)pData->dbNcoll, doc, NULL)) {
dbgprintf("ommongodb: insert error\n");
+ reportMongoError(pData);
ABORT_FINALIZE(RS_RET_ERR);
}