Slaves list in INFO output: lag added, format changed.
There is a new 'lag' information in the list of slaves, in the "replication" section of the INFO output. Also the format was changed in a backward incompatible way in order to make it more easy to parse if new fields are added in the future, as the new format is comma separated but has named fields (no longer positional fields).
This commit is contained in:
parent
be6182c26a
commit
db72ecccc8
10
src/redis.c
10
src/redis.c
@ -2323,6 +2323,7 @@ sds genRedisInfoString(char *section) {
|
|||||||
char *state = NULL;
|
char *state = NULL;
|
||||||
char ip[32];
|
char ip[32];
|
||||||
int port;
|
int port;
|
||||||
|
long lag = 0;
|
||||||
|
|
||||||
if (anetPeerToString(slave->fd,ip,&port) == -1) continue;
|
if (anetPeerToString(slave->fd,ip,&port) == -1) continue;
|
||||||
switch(slave->replstate) {
|
switch(slave->replstate) {
|
||||||
@ -2338,9 +2339,14 @@ sds genRedisInfoString(char *section) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (state == NULL) continue;
|
if (state == NULL) continue;
|
||||||
info = sdscatprintf(info,"slave%d:%s,%d,%s,%lld\r\n",
|
if (slave->replstate == REDIS_REPL_ONLINE)
|
||||||
|
lag = time(NULL) - slave->repl_ack_time;
|
||||||
|
|
||||||
|
info = sdscatprintf(info,
|
||||||
|
"slave%d:ip=%s,port=%d,state=%s,"
|
||||||
|
"repl_offset=%lld,lag=%ld\r\n",
|
||||||
slaveid,ip,slave->slave_listening_port,state,
|
slaveid,ip,slave->slave_listening_port,state,
|
||||||
slave->repl_ack_off);
|
slave->repl_ack_off, lag);
|
||||||
slaveid++;
|
slaveid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user