diff options
author | dormando <dormando@rydia.net> | 2009-03-27 16:12:46 -0700 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-03-30 14:11:03 -0700 |
commit | 3d540bdbe423c674dba899266d3d678e2b19c47e (patch) | |
tree | 8a7a86e34b1c6629b2a518dc28750c67ff2cd266 | |
parent | 534466e0dcbc7e385585ebd456a35d0beded2f47 (diff) | |
download | memcached-3d540bdbe423c674dba899266d3d678e2b19c47e.tar.gz |
two new troubleshooting stats
accepting_conns for completeness, and listen_disabled_num to see how many
times you've hit maxconns and disabled incoming connections. probably a good
stat to monitor and flip out on.
-rw-r--r-- | memcached.c | 19 | ||||
-rw-r--r-- | memcached.h | 3 | ||||
-rwxr-xr-x | t/stats.t | 7 |
3 files changed, 23 insertions, 6 deletions
diff --git a/memcached.c b/memcached.c index 0464825..12322de 100644 --- a/memcached.c +++ b/memcached.c @@ -160,7 +160,8 @@ static rel_time_t realtime(const time_t exptime) { static void stats_init(void) { stats.curr_items = stats.total_items = stats.curr_conns = stats.total_conns = stats.conn_structs = 0; stats.get_cmds = stats.set_cmds = stats.get_hits = stats.get_misses = stats.evictions = 0; - stats.curr_bytes = 0; + stats.curr_bytes = stats.listen_disabled_num = 0; + stats.accepting_conns = 1; /* assuming we start in this state. */ /* make the time we started always be 2 seconds before we really did, so time(0) - time.started is never zero. if so, things @@ -2224,7 +2225,8 @@ static char *server_stats(uint32_t (*add_stats)(char *buf, const char *key, APPEND_STAT("bytes_read", "%llu", (unsigned long long)thread_stats.bytes_read); APPEND_STAT("bytes_written", "%llu", (unsigned long long)thread_stats.bytes_written); APPEND_STAT("limit_maxbytes", "%llu", (unsigned long long)settings.maxbytes); - APPEND_STAT("bytes_written", "%llu", (unsigned long long)thread_stats.bytes_written); + APPEND_STAT("accepting_conns", "%u", stats.accepting_conns); + APPEND_STAT("listen_disabled_num", "%llu", (unsigned long long)stats.listen_disabled_num); APPEND_STAT("threads", "%d", settings.num_threads); if(*buflen > 0 && (buf = malloc(*buflen)) == NULL) { @@ -3242,7 +3244,18 @@ void accept_new_conns(const bool do_accept) { perror("listen"); } } - } + } + + if (do_accept) { + STATS_LOCK(); + stats.accepting_conns = 1; + STATS_UNLOCK(); + } else { + STATS_LOCK(); + stats.accepting_conns = 0; + stats.listen_disabled_num++; + STATS_UNLOCK(); + } } /* diff --git a/memcached.h b/memcached.h index b6c4113..3ca2eef 100644 --- a/memcached.h +++ b/memcached.h @@ -108,6 +108,9 @@ struct stats { uint64_t get_hits; uint64_t get_misses; uint64_t evictions; + time_t started; /* when the process was started */ + unsigned int accepting_conns; /* whether we are currently accepting */ + uint64_t listen_disabled_num; }; #define MAX_VERBOSITY_LEVEL 2 @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -use Test::More tests => 91; +use Test::More tests => 93; use FindBin qw($Bin); use lib "$Bin/lib"; use MemcachedTest; @@ -47,14 +47,15 @@ my $sock = $server->sock; my $stats = mem_stats($sock); # Test number of keys -is(scalar(keys(%$stats)), 32, "32 stats values"); +is(scalar(keys(%$stats)), 34, "34 stats values"); # Test initial state foreach my $key (qw(curr_items total_items bytes cmd_get cmd_set get_hits evictions get_misses bytes_written delete_hits delete_misses incr_hits incr_misses decr_hits - decr_misses)) { + decr_misses listen_disabled_num)) { is($stats->{$key}, 0, "initial $key is zero"); } +is($stats->{accepting_conns}, 1, "initial accepting_conns is one"); # Do some operations |