summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84ab8ed)
raw | patch | inline | side by side (parent: 84ab8ed)
author | Victor Seva <linuxmaniac@torreviejawireless.org> | |
Thu, 14 Nov 2013 10:59:32 +0000 (11:59 +0100) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Fri, 7 Nov 2014 21:46:20 +0000 (22:46 +0100) |
Conflicts:
README
README
README | patch | blob | history | |
configure.ac | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/write_redis.c | patch | blob | history |
index 3e3a030ba409332c704e74a878a78ff3e0dd3390..e749a5f32ffde4dbe1dbe3e95d4f582f7829e8e8 100644 (file)
--- a/README
+++ b/README
* libclntsh (optional)
Used by the `oracle' plugin.
- * libcredis (optional)
- Used by the `redis' plugin. Please note that you require a 0.2.2 version
- or higher. <http://code.google.com/p/credis/>
+ * libhiredis (optional)
+ Used by the redis plugin. Please note that you require a 0.10.0 version
+ or higher. <https://github.com/redis/hiredis>
* libcurl (optional)
If you want to use the `apache', `ascent', `bind', `curl', `curl_json',
diff --git a/configure.ac b/configure.ac
index 15fdd17c858e21be1382c8252d48d766b3129dca..9c3dfed3741c9451c4956ebb8a5be26f28baba14 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
# }}}
-# --with-libcredis {{{
-AC_ARG_WITH(libcredis, [AS_HELP_STRING([--with-libcredis@<:@=PREFIX@:>@], [Path to libcredis.])],
-[
- if test "x$withval" = "xyes"
- then
- with_libcredis="yes"
- else if test "x$withval" = "xno"
- then
- with_libcredis="no"
- else
- with_libcredis="yes"
- LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
- LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libcredis="yes"])
-
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-
-CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
-
-if test "x$with_libcredis" = "xyes"
-then
- if test "x$LIBCREDIS_CPPFLAGS" != "x"
- then
- AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
- fi
- AC_CHECK_HEADERS(credis.h,
- [with_libcredis="yes"],
- [with_libcredis="no (credis.h not found)"])
-fi
-if test "x$with_libcredis" = "xyes"
-then
- if test "x$LIBCREDIS_LDFLAGS" != "x"
- then
- AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
- fi
- AC_CHECK_LIB(credis, credis_info,
- [with_libcredis="yes"],
- [with_libcredis="no (symbol 'credis_info' not found)"])
-
-fi
-
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-
-if test "x$with_libcredis" = "xyes"
-then
- BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS"
- BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS"
- AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS)
- AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
-# }}}
-
# --with-libhiredis {{{
AC_ARG_WITH(libhiredis, [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@],
[Path to libhiredis.])],
AC_PLUGIN([write_http], [$with_libcurl], [HTTP output plugin])
AC_PLUGIN([write_kafka], [$with_librdkafka], [Kafka output plugin])
AC_PLUGIN([write_mongodb], [$with_libmongoc], [MongoDB output plugin])
-AC_PLUGIN([write_redis], [$with_libcredis], [Redis output plugin])
+AC_PLUGIN([write_redis], [$with_libhiredis], [Redis output plugin])
AC_PLUGIN([write_riemann], [$have_protoc_c], [Riemann output plugin])
AC_PLUGIN([write_tsdb], [yes], [TSDB output plugin])
AC_PLUGIN([xmms], [$with_libxmms], [XMMS statistics])
libaquaero5 . . . . . $with_libaquaero5
libcurl . . . . . . . $with_libcurl
libdbi . . . . . . . $with_libdbi
- libcredis . . . . . . $with_libcredis
libhiredis . . . . . $with_libhiredis
libesmtp . . . . . . $with_libesmtp
libganglia . . . . . $with_libganglia
diff --git a/src/Makefile.am b/src/Makefile.am
index ee7cf6ba2006639b17fb694f98dcfc2b078945cc..71d4c96a10a99e3c7807ea19144eb47964077d1c 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
if BUILD_PLUGIN_WRITE_REDIS
pkglib_LTLIBRARIES += write_redis.la
write_redis_la_SOURCES = write_redis.c
-write_redis_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBCREDIS_LDFLAGS)
-write_redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCREDIS_CPPFLAGS)
-write_redis_la_LIBADD = -lcredis
+write_redis_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBHIREDIS_LDFLAGS)
+write_redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
+write_redis_la_LIBADD = -lhiredis
endif
if BUILD_PLUGIN_WRITE_RIEMANN
diff --git a/src/write_redis.c b/src/write_redis.c
index 3defacae029b57c4a213610e9b01afa71d9bb029..1b127451309bfe902a40a5d68fa33b7e49fe428a 100644 (file)
--- a/src/write_redis.c
+++ b/src/write_redis.c
#include "configfile.h"
#include <pthread.h>
-#include <credis.h>
+#include <sys/time.h>
+#include <hiredis/hiredis.h>
struct wr_node_s
{
char *host;
int port;
- int timeout;
+ struct timeval timeout;
- REDIS conn;
+ redisContext *conn;
pthread_mutex_t lock;
};
typedef struct wr_node_s wr_node_t;
size_t value_size;
char *value_ptr;
int status;
+ redisReply *rr;
int i;
status = FORMAT_VL (ident, sizeof (ident), vl);
if (node->conn == NULL)
{
- node->conn = credis_connect (node->host, node->port, node->timeout);
+ node->conn = redisConnectWithTimeout ((char *)node->host, node->port, node->timeout);
if (node->conn == NULL)
{
ERROR ("write_redis plugin: Connecting to host \"%s\" (port %i) failed.",
}
}
- /* "credis_zadd" doesn't handle a NULL pointer gracefully, so I'd rather
- * have a meaningful assertion message than a normal segmentation fault. */
assert (node->conn != NULL);
- status = credis_zadd (node->conn, key, (double) vl->time, value);
+ rr = redisCommand (node->conn, "ZADD %b %f %b", key, sizeof (key),
+ (double) vl->time, value, sizeof (value));
+ if (rr==NULL)
+ WARNING("ZADD command error. key:%s", key);
- credis_sadd (node->conn, "collectd/values", ident);
+ rr = redisCommand (node->conn, "SADD collectd/values %b", ident, sizeof(ident));
+ if (rr==NULL)
+ WARNING("SADD command error. ident:%s", ident);
pthread_mutex_unlock (&node->lock);
if (node->conn != NULL)
{
- credis_close (node->conn);
+ redisFree (node->conn);
node->conn = NULL;
}
static int wr_config_node (oconfig_item_t *ci) /* {{{ */
{
wr_node_t *node;
+ int timeout;
int status;
int i;
memset (node, 0, sizeof (*node));
node->host = NULL;
node->port = 0;
- node->timeout = 1000;
+ node->timeout.tv_sec = 0;
+ node->timeout.tv_usec = 1000;
node->conn = NULL;
pthread_mutex_init (&node->lock, /* attr = */ NULL);
status = 0;
}
}
- else if (strcasecmp ("Timeout", child->key) == 0)
- status = cf_util_get_int (child, &node->timeout);
+ else if (strcasecmp ("Timeout", child->key) == 0) {
+ status = cf_util_get_int (child, &timeout);
+ if (status == 0) node->timeout.tv_usec = timeout;
+ }
else
WARNING ("write_redis plugin: Ignoring unknown config option \"%s\".",
child->key);