Commit 503d87a8 authored by antirez's avatar antirez
Browse files

List connected slaves with ip,port,state information in INFO, as requested by github issue #219

parent 19951d96
...@@ -1611,6 +1611,37 @@ sds genRedisInfoString(char *section) { ...@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment