summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 97f247e)
raw | patch | inline | side by side (parent: 97f247e)
author | bufadu <bufadu@gmail.com> | |
Fri, 5 May 2017 12:43:44 +0000 (14:43 +0200) | ||
committer | bufadu <bufadu@gmail.com> | |
Fri, 5 May 2017 12:43:44 +0000 (14:43 +0200) |
src/redis.c | patch | blob | history |
diff --git a/src/redis.c b/src/redis.c
index 4bfa3cffdaa1cb0b715bf842ba3a97070f69e332..40a311d135df632dc1a6c02d341dda10e25901f4 100644 (file)
--- a/src/redis.c
+++ b/src/redis.c
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';