From 7a02bef3ed2adcdd6c7f8cf07eaad2aaa84bee2c Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Mon, 10 Nov 2014 07:58:13 +0100 Subject: [PATCH] write_redis: fix format of commands sent to redis The commands getting submitted to redis now look like this: "ZADD" "collectd/hostname/entropy/entropy" "1415602051.335973024" "1415602051.335973024:823" "SADD" "collectd/values" "hostname/entropy/entropy" ... which is the same as in the initial implementation, except for the added decimals in the timestamp (the plugin was developped before high-precision timestamps support was added to collectd). --- src/write_redis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/write_redis.c b/src/write_redis.c index 5ed95fb9..28d475fe 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -86,7 +86,7 @@ static int wr_write (const data_set_t *ds, /* {{{ */ } \ } while (0) - APPEND ("%lu:", (unsigned long) vl->time); + APPEND ("%.9f:", CDTIME_T_TO_DOUBLE(vl->time)); for (i = 0; i < ds->ds_num; i++) { if (ds->ds[i].type == DS_TYPE_COUNTER) @@ -119,12 +119,12 @@ static int wr_write (const data_set_t *ds, /* {{{ */ } assert (node->conn != NULL); - rr = redisCommand (node->conn, "ZADD %b %f %b", key, sizeof (key), - (double) vl->time, value, sizeof (value)); + rr = redisCommand (node->conn, "ZADD %s %.9f %s", key, + CDTIME_T_TO_DOUBLE(vl->time), value); if (rr==NULL) WARNING("ZADD command error. key:%s", key); - rr = redisCommand (node->conn, "SADD collectd/values %b", ident, sizeof(ident)); + rr = redisCommand (node->conn, "SADD collectd/values %s", ident); if (rr==NULL) WARNING("SADD command error. ident:%s", ident); -- 2.30.2