diff options
author | antirez <antirez@gmail.com> | 2011-01-14 10:20:02 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-01-14 10:20:35 +0100 |
commit | ebb07fb4bbe971460df206f5c2fded037207d7b0 (patch) | |
tree | 60ea9ac7883885563229f1a94bd365efd29c07c0 | |
parent | c13c4080e513cda2a1f1fce593ec45fb3a3c9666 (diff) | |
download | redis-ebb07fb4bbe971460df206f5c2fded037207d7b0.tar.gz |
implemented two new INFO fields showing the size of clients max input and output buffers.
-rw-r--r-- | src/networking.c | 19 | ||||
-rw-r--r-- | src/redis.c | 5 | ||||
-rw-r--r-- | src/redis.h | 2 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/networking.c b/src/networking.c index 79596bc24..9716ca319 100644 --- a/src/networking.c +++ b/src/networking.c @@ -821,3 +821,22 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { } processInputBuffer(c); } + +void getClientsMaxBuffers(unsigned long *longest_output_list, + unsigned long *biggest_input_buffer) { + redisClient *c; + listNode *ln; + listIter li; + unsigned long lol = 0, bib = 0; + + listRewind(server.clients,&li); + while ((ln = listNext(&li)) != NULL) { + c = listNodeValue(ln); + + if (listLength(c->reply) > lol) lol = listLength(c->reply); + if (sdslen(c->querybuf) > bib) bib = sdslen(c->querybuf); + } + *longest_output_list = lol; + *biggest_input_buffer = bib; +} + diff --git a/src/redis.c b/src/redis.c index fa01d7c3b..2b7935e3a 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1141,9 +1141,11 @@ sds genRedisInfoString(void) { int j; char hmem[64]; struct rusage self_ru, c_ru; + unsigned long lol, bib; getrusage(RUSAGE_SELF, &self_ru); getrusage(RUSAGE_CHILDREN, &c_ru); + getClientsMaxBuffers(&lol,&bib); bytesToHuman(hmem,zmalloc_used_memory()); info = sdscatprintf(sdsempty(), @@ -1162,6 +1164,8 @@ sds genRedisInfoString(void) { "used_cpu_user_childrens:%.2f\r\n" "connected_clients:%d\r\n" "connected_slaves:%d\r\n" + "client_longest_output_list:%lu\r\n" + "client_biggest_input_buf:%lu\r\n" "blocked_clients:%d\r\n" "used_memory:%zu\r\n" "used_memory_human:%s\r\n" @@ -1201,6 +1205,7 @@ sds genRedisInfoString(void) { (float)c_ru.ru_stime.tv_sec+(float)c_ru.ru_stime.tv_usec/1000000, listLength(server.clients)-listLength(server.slaves), listLength(server.slaves), + lol, bib, server.bpop_blocked_clients, zmalloc_used_memory(), hmem, diff --git a/src/redis.h b/src/redis.h index 6d212edad..4fea3a44f 100644 --- a/src/redis.h +++ b/src/redis.h @@ -656,6 +656,8 @@ void addReplyDouble(redisClient *c, double d); void addReplyLongLong(redisClient *c, long long ll); void addReplyMultiBulkLen(redisClient *c, long length); void *dupClientReplyValue(void *o); +void getClientsMaxBuffers(unsigned long *longest_output_list, + unsigned long *biggest_input_buffer); #ifdef __GNUC__ void addReplyErrorFormat(redisClient *c, const char *fmt, ...) |