From: Marc Fournier Date: Mon, 10 Nov 2014 06:58:13 +0000 (+0100) Subject: write_redis: fix format of commands sent to redis X-Git-Tag: collectd-5.5.0~139^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7a02bef3ed2adcdd6c7f8cf07eaad2aaa84bee2c;p=collectd.git 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). --- 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);