* 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',
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
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
#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);