From 212ef86c9038207108837448ec4eafd8d4ab0cb9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 3 Nov 2010 15:13:28 +0100 Subject: [PATCH] write_mongo plugin: Build fixes. 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 | 2 +- src/Makefile.am | 20 +++++++++----------- src/write_mongo.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index 186082a5..387c2201 100644 --- a/configure.in +++ b/configure.in @@ -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]) diff --git a/src/Makefile.am b/src/Makefile.am index 37012512..757efa22 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/write_mongo.c b/src/write_mongo.c index 1f7e3d09..b20d0c9b 100644 --- a/src/write_mongo.c +++ b/src/write_mongo.c @@ -31,8 +31,13 @@ #include "configfile.h" #include -#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 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); -- 2.11.0