summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 26e39b8)
raw | patch | inline | side by side (parent: 26e39b8)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 3 Nov 2010 14:13:28 +0000 (15:13 +0100) | ||
committer | Chris 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".
"MONGO_HAVE_STDINT" define into the .c file. Avoid the poisoned "strcpy".
configure.in | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/write_mongo.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 186082a5af1dedb35d287d91a19b921d7a1eeca0..387c2201c48de11e7dbf7545c17476ddcb505338 100644 (file)
--- a/configure.in
+++ b/configure.in
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])
diff --git a/src/Makefile.am b/src/Makefile.am
index 37012512efbf69408c92bd0ec47d49c2ce91fc27..757efa22180387a8634b8f606bc01787ea11e091 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
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
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
diff --git a/src/write_mongo.c b/src/write_mongo.c
index 1f7e3d096525007ff3656c16af4b56310469ea9b..b20d0c9bf82644d21efb8d6af6cce7efddaf3ede 100644 (file)
--- a/src/write_mongo.c
+++ b/src/write_mongo.c
#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
{
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);