mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
List connected slaves with ip,port,state information in INFO, as requested by github issue #219
This commit is contained in:
parent
19951d965a
commit
503d87a818
31
src/redis.c
31
src/redis.c
@ -1611,6 +1611,37 @@ sds genRedisInfoString(char *section) {
|
|||||||
info = sdscatprintf(info,
|
info = sdscatprintf(info,
|
||||||
"connected_slaves:%d\r\n",
|
"connected_slaves:%d\r\n",
|
||||||
listLength(server.slaves));
|
listLength(server.slaves));
|
||||||
|
if (listLength(server.slaves)) {
|
||||||
|
int slaveid = 0;
|
||||||
|
listNode *ln;
|
||||||
|
listIter li;
|
||||||
|
|
||||||
|
listRewind(server.slaves,&li);
|
||||||
|
while((ln = listNext(&li))) {
|
||||||
|
redisClient *slave = listNodeValue(ln);
|
||||||
|
char *state = NULL;
|
||||||
|
char ip[32];
|
||||||
|
int port;
|
||||||
|
|
||||||
|
if (anetPeerToString(slave->fd,ip,&port) == -1) continue;
|
||||||
|
switch(slave->replstate) {
|
||||||
|
case REDIS_REPL_WAIT_BGSAVE_START:
|
||||||
|
case REDIS_REPL_WAIT_BGSAVE_END:
|
||||||
|
state = "wait_bgsave";
|
||||||
|
break;
|
||||||
|
case REDIS_REPL_SEND_BULK:
|
||||||
|
state = "send_bulk";
|
||||||
|
break;
|
||||||
|
case REDIS_REPL_ONLINE:
|
||||||
|
state = "online";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (state == NULL) continue;
|
||||||
|
info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n",
|
||||||
|
slaveid,ip,port,state);
|
||||||
|
slaveid++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CPU */
|
/* CPU */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user