write_mongo plugin: Build fixes.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Wed, 3 Nov 2010 14:13:28 +0000 (15:13 +0100)
committerChris Lundquist <chris.lundquist@bluebox.net>
Tue, 24 Jan 2012 19:53:22 +0000 (11:53 -0800)
Enable the "write_mongo" plugin when the library is available. Move the
"MONGO_HAVE_STDINT" define into the .c file. Avoid the poisoned "strcpy".

configure.in
src/Makefile.am
src/write_mongo.c

index 186082a..387c220 100644 (file)
@@ -4688,7 +4688,7 @@ AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
 AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
 AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
-AC_PLUGIN([write_mongo], [yes],    [Mongo output plugin])
+AC_PLUGIN([write_mongo], [$with_libmongoc],    [MongoDB output plugin])
 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
 AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
 
index 3701251..757efa2 100644 (file)
@@ -1243,6 +1243,15 @@ endif
 collectd_DEPENDENCIES += write_http.la
 endif
 
+if BUILD_PLUGIN_WRITE_MONGO
+pkglib_LTLIBRARIES += write_mongo.la
+write_mongo_la_SOURCES = write_mongo.c
+write_mongo_la_LDFLAGS = -module -avoid-version
+write_mongo_la_LIBADD = -lmongoc
+collectd_LDADD += "-dlopen" write_mongo.la
+collectd_DEPENDENCIES += write_mongo.la
+endif
+
 if BUILD_PLUGIN_WRITE_REDIS
 pkglib_LTLIBRARIES += write_redis.la
 write_redis_la_SOURCES = write_redis.c
@@ -1253,17 +1262,6 @@ collectd_LDADD += "-dlopen" write_redis.la
 collectd_DEPENDENCIES += write_redis.la
 endif
 
-if BUILD_PLUGIN_WRITE_MONGO
-pkglib_LTLIBRARIES += write_mongo.la
-write_mongo_la_SOURCES = write_mongo.c
-write_mongo_la_LDFLAGS = -module -avoid-version
-write_mongo_la_CFLAGS = -DMONGO_HAVE_STDINT $(AM_CFLAGS)
-write_mongo_la_LIBADD = libmongo/libmongo.la
-write_mongo_la_DEPENDENCIES = libmongo/libmongo.la
-collectd_LDADD += "-dlopen" write_mongo.la
-collectd_DEPENDENCIES += write_mongo.la
-endif
-
 if BUILD_PLUGIN_XMMS
 pkglib_LTLIBRARIES += xmms.la
 xmms_la_SOURCES = xmms.c
index 1f7e3d0..b20d0c9 100644 (file)
 #include "configfile.h"
 
 #include <pthread.h>
-#include "libmongo/bson.h"
-#include "libmongo/mongo.h"
+
+#if HAVE_STDINT_H
+# define MONGO_HAVE_STDINT 1
+#else
+# define MONGO_USE_LONG_LONG_INT 1
+#endif
+#include <mongo.h>
 
 struct wm_node_s
 {
@@ -93,7 +98,8 @@ static int wm_write (const data_set_t *ds, /* {{{ */
 
   if (node->connected == 0)
   {
-    strcpy(node->opts->host, node->host);
+    sstrncpy(node->opts->host, node->host,
+        sizeof (node->opts->host));
     node->opts->port = node->port;
 
     status = mongo_connect(node->conn,node->opts);