教程 > memcached 教程 > 阅读:32

memcached stats 命令——迹忆客-ag捕鱼王app官网

memcached stats命令用于返回服务器统计信息,如 pid、版本、连接信息等。

语法:

stats 命令的基本语法格式如下:

stats

示例

在以下示例中,我们使用了 stats 命令来输出 memcached 服务信息。

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

使用 java 应用程序获取服务信息

要从 memcached 服务器获取统计信息需要使用 memcached stats方法。

import net.spy.memcached.memcachedclient;
public class memcachedjava {
   public static void main(string[] args) {
      
      // 连接 memcached 服务
      memcachedclient mcc = new memcachedclient(new
      inetsocketaddress("127.0.0.1", 11211));
      system.out.println("connection to server successful");
      system.out.println("stats:" mcc.stats);
   }
}

在编译和执行程序时,输出以下结果:

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]]

查看笔记

扫码一下
查看教程更方便
网站地图