From: bufadu Date: Fri, 5 May 2017 12:43:44 +0000 (+0200) Subject: redis: fix parser and comments X-Git-Tag: collectd-5.8.0~190^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3c8488fb94c70e10d38f66cfd7ca85d185eb473b;p=collectd.git redis: fix parser and comments --- diff --git a/src/redis.c b/src/redis.c index 4bfa3cff..40a311d1 100644 --- a/src/redis.c +++ b/src/redis.c @@ -356,22 +356,28 @@ static int redis_handle_query(redisContext *rh, redis_node_t *rn, static int redis_db_stats(char *node, char const *info_line) /* {{{ */ { + /* redis_db_stats parses and dispatches Redis database statistics, + * currently the number of keys for each database. + * info_line needs to have the following format: + * db0:keys=4,expires=0,avg_ttl=0 + */ + for (int db = 0; db < REDIS_DEF_DB_COUNT; db++) { static char buf[MAX_REDIS_VAL_SIZE]; - static char field_name[10]; + static char field_name[11]; static char db_id[3]; value_t val; char *str; int i; - ssnprintf(field_name, sizeof(field_name), "db%d:keys", db); + ssnprintf(field_name, sizeof(field_name), "db%d:keys=", db); str = strstr(info_line, field_name); if (!str) continue; - str += strlen(field_name) + 1; /* also skip the '=' */ - for (i = 0; (*str && (isdigit((int)*str) || *str == '.')); i++, str++) + str += strlen(field_name); + for (i = 0; (*str && isdigit((int)*str)); i++, str++) buf[i] = *str; buf[i] = '\0';