- Memcached 基础
- Memcached - 主页
- Memcached - 概览
- Memcached - 环境
- Memcached - 连接
- Memcached 存储命令
- Memcached - 设置数据
- Memcached - 添加数据
- Memcached - 替换数据
- Memcached - 追加数据
- Memcached - 前置数据
- Memcached - CAS
- Memcached 检索命令
- Memcached - 获取数据
- Memcached - 获取 CAS 数据
- Memcached - 删除键
- Memcached - 删除数据
- Memcached - Incr/Decr
- Memcached 统计命令
- Memcached - 统计信息
- Memcached - 统计项
- Memcached - 统计 slab
- Memcached - 统计大小
- Memcached - 清除数据
- Memcached 实用资源
- Memcached - 快速指南
- Memcached - 实用资源
- Memcached - 讨论
Memcached - 统计信息
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
使用 Java 应用程序的统计信息
要从 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 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]]
广告