memcached stats command is used to return server statistics such as pid, version, connections, etc.
syntax
the basic syntax of memcached stats command is as shown below −
stats
example
stats stat pid 1162 stat uptime 5022 stat time 1415208270 stat version 1.4.14 stat libevent 2.0.19-stable stat pointer_size 64 stat rusage_user 0.096006 stat rusage_system 0.152009 stat curr_connections 5 stat total_connections 6 stat connection_structures 6 stat reserved_fds 20 stat cmd_get 6 stat cmd_set 4 stat cmd_flush 0 stat cmd_touch 0 stat get_hits 4 stat get_misses 2 stat delete_misses 1 stat delete_hits 1 stat incr_misses 2 stat incr_hits 1 stat decr_misses 0 stat decr_hits 1 stat cas_misses 0 stat cas_hits 0 stat cas_badval 0 stat touch_hits 0 stat touch_misses 0 stat auth_cmds 0 stat auth_errors 0 stat bytes_read 262 stat bytes_written 313 stat limit_maxbytes 67108864 stat accepting_conns 1 stat listen_disabled_num 0 stat threads 4 stat conn_yields 0 stat hash_power_level 16 stat hash_bytes 524288 stat hash_is_expanding 0 stat expired_unfetched 1 stat evicted_unfetched 0 stat bytes 142 stat curr_items 2 stat total_items 6 stat evictions 0 stat reclaimed 1 end
stats using java application
to get stats from a memcached server, you need to use the memcached stats method.
example
import net.spy.memcached.memcachedclient;
public class memcachedjava {
public static void main(string[] args) {
// connecting to memcached server on localhost
memcachedclient mcc = new memcachedclient(new
inetsocketaddress("127.0.0.1", 11211));
system.out.println("connection to server successful");
system.out.println("stats:"+mcc.stats);
}
}
output
on compiling and executing the program, you get to see the following output −
connection to server successful stats:[/127.0.0.1:11211:[delete_hits:0, bytes:71, total_items:4, rusage_system:0.220013, touch_misses:0, cmd_touch:0, listen_disabled_num:0, auth_errors:0, evictions:0, version:1.4.14, pointer_size:64, time:1417279366, incr_hits:1, threads:4, expired_unfetched:0, limit_maxbytes:67108864, hash_is_expanding:0, bytes_read:170, curr_connections:8, get_misses:1, reclaimed:0, bytes_written:225, hash_power_level:16, connection_structures:9, cas_hits:0, delete_misses:0, total_connections:11, rusage_user:0.356022, cmd_flush:0, libevent:2.0.19-stable, uptime:12015, reserved_fds:20, touch_hits:0, cas_badval:0, pid:1138, get_hits:2, curr_items:1, cas_misses:0, accepting_conns:1, evicted_unfetched:0, cmd_get:3, cmd_set:2, auth_cmds:0, incr_misses:1, hash_bytes:524288, decr_misses:1, decr_hits:1, conn_yields:0]]