memcached的stats命令用于返回就类似pid,版本,连接等服务器统计
memcached的stats命令的基本语法如下所示:
stats
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
为了得到memcached服务器的统计,需要使用memcached的stats方法。
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 sucessfully"); system.out.println("stats:"+mcc.stats); } }
当上述程序编译和运行,它提供了以下的输出:
connection to server successfully stats:[/127.0.0.1:11211:[delete_hits:0, bytes:71, total_items:4, rusage_system:0.2