X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fredis.c;h=ca17e2994a0d8e4fecbca3978c864272b3c0d588;hb=251897b1633940104c95945d3dd29981e43a0cbf;hp=68158ed20c7883cbf3cf32e30d33e0ba9dd91b30;hpb=733f11a209aa9678db4a6d8dc1086fd1854115fb;p=collectd.git diff --git a/src/redis.c b/src/redis.c index 68158ed2..ca17e299 100644 --- a/src/redis.c +++ b/src/redis.c @@ -317,12 +317,14 @@ static int redis_handle_query(redisContext *rh, redis_node_t *rn, ds = plugin_get_ds(rq->type); if (!ds) { - ERROR("redis plugin: DataSet `%s' not defined.", rq->type); + ERROR("redis plugin: DS type `%s' not defined.", rq->type); return -1; } if (ds->ds_num != 1) { - ERROR("redis plugin: DS `%s' has too many types.", rq->type); + ERROR("redis plugin: DS type `%s' has too many datasources. This is not " + "supported currently.", + rq->type); return -1; } @@ -356,13 +358,24 @@ static int redis_handle_query(redisContext *rh, redis_node_t *rn, break; case REDIS_REPLY_STRING: if (parse_value(rr->str, &val, ds->ds[0].type) == -1) { - WARNING("redis plugin: Unable to parse field `%s'.", rq->type); + WARNING("redis plugin: Query `%s': Unable to parse value.", rq->query); freeReplyObject(rr); return -1; } break; + case REDIS_REPLY_ERROR: + WARNING("redis plugin: Query `%s' failed: %s.", rq->query, rr->str); + freeReplyObject(rr); + return -1; + case REDIS_REPLY_ARRAY: + WARNING("redis plugin: Query `%s' should return string or integer. Arrays " + "are not supported.", + rq->query); + freeReplyObject(rr); + return -1; default: - WARNING("redis plugin: Cannot coerce redis type."); + WARNING("redis plugin: Query `%s': Cannot coerce redis type (%i).", + rq->query, rr->type); freeReplyObject(rr); return -1; } @@ -423,8 +436,13 @@ static int redis_read(void) /* {{{ */ rh = redisConnectWithTimeout((char *)rn->host, rn->port, rn->timeout); if (rh == NULL) { - ERROR("redis plugin: unable to connect to node `%s' (%s:%d).", rn->name, - rn->host, rn->port); + ERROR("redis plugin: can't allocate redis context"); + continue; + } + if (rh->err) { + ERROR("redis plugin: unable to connect to node `%s' (%s:%d): %s.", + rn->name, rn->host, rn->port, rh->errstr); + redisFree(rh); continue; }