提交 e31b615e 编写于 作者: A antirez

Better MONITOR output, now includes client ip:port or the lua string if the...

Better MONITOR output, now includes client ip:port or the lua string if the command was executed by the scripting engine.
上级 7b845b62
...@@ -1248,7 +1248,7 @@ void call(redisClient *c, int flags) { ...@@ -1248,7 +1248,7 @@ void call(redisClient *c, int flags) {
/* Sent the command to clients in MONITOR mode, only if the commands are /* Sent the command to clients in MONITOR mode, only if the commands are
* not geneated from reading an AOF. */ * not geneated from reading an AOF. */
if (listLength(server.monitors) && !server.loading) if (listLength(server.monitors) && !server.loading)
replicationFeedMonitors(server.monitors,c->db->id,c->argv,c->argc); replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc);
/* Call the command. */ /* Call the command. */
redisOpArrayInit(&server.also_propagate); redisOpArrayInit(&server.also_propagate);
......
...@@ -932,7 +932,7 @@ int syncReadLine(int fd, char *ptr, ssize_t size, int timeout); ...@@ -932,7 +932,7 @@ int syncReadLine(int fd, char *ptr, ssize_t size, int timeout);
/* Replication */ /* Replication */
void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc); void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc);
void replicationFeedMonitors(list *monitors, int dictid, robj **argv, int argc); void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **argv, int argc);
void updateSlavesWaitingBgsave(int bgsaveerr); void updateSlavesWaitingBgsave(int bgsaveerr);
void replicationCron(void); void replicationCron(void);
......
...@@ -50,17 +50,23 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) { ...@@ -50,17 +50,23 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
} }
} }
void replicationFeedMonitors(list *monitors, int dictid, robj **argv, int argc) { void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **argv, int argc) {
listNode *ln; listNode *ln;
listIter li; listIter li;
int j; int j, port;
sds cmdrepr = sdsnew("+"); sds cmdrepr = sdsnew("+");
robj *cmdobj; robj *cmdobj;
char ip[32];
struct timeval tv; struct timeval tv;
gettimeofday(&tv,NULL); gettimeofday(&tv,NULL);
cmdrepr = sdscatprintf(cmdrepr,"%ld.%06ld ",(long)tv.tv_sec,(long)tv.tv_usec); cmdrepr = sdscatprintf(cmdrepr,"%ld.%06ld ",(long)tv.tv_sec,(long)tv.tv_usec);
if (dictid != 0) cmdrepr = sdscatprintf(cmdrepr,"(db %d) ", dictid); if (c->flags & REDIS_LUA_CLIENT) {
cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ", dictid);
} else {
anetPeerToString(c->fd,ip,&port);
cmdrepr = sdscatprintf(cmdrepr,"[%d %s:%d] ", dictid,ip,port);
}
for (j = 0; j < argc; j++) { for (j = 0; j < argc; j++) {
if (argv[j]->encoding == REDIS_ENCODING_INT) { if (argv[j]->encoding == REDIS_ENCODING_INT) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册