logo图片
Memcached教程

Memcached stats

有许多不同的命令可返回Memcached服务器的计数器和设置。可以通过各种各样的工具或仅通过telnet或netcat来检查这些。
这些命令是:

Memcached-统计信息

Memcached stats(Statistics)是用于返回服务器统计信息(例如PID,版本,连接等)的命令。

语法:

stats

Ubuntu中的示例

stats
STAT pid 686
STAT uptime 90
STAT time 1557850817
STAT version 1.5.6 Ubuntu
STAT libevent 2.1.8-stable
STAT pointer_size 64
STAT rusage_user 0.026998
STAT rusage_system 0.053997
STAT max_connections 1024
STAT curr_connections 1
STAT total_connections 2
STAT rejected_connections 0
STAT connection_structures 2
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 0
STAT get_expired 0
STAT get_flushed 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
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 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT time_in_listen_disabled_us 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT slab_reassign_rescues 0
STAT slab_reassign_chunk_rescues 0
STAT slab_reassign_evictions_nomem 0
STAT slab_reassign_inline_reclaim 0
STAT slab_reassign_busy_items 0
STAT slab_reassign_busy_deletes 0
STAT slab_reassign_running 0
STAT slabs_moved 0
STAT lru_crawler_running 0
STAT lru_crawler_starts 510
STAT lru_maintainer_juggles 138
STAT malloc_fails 0
STAT log_worker_dropped 0
STAT log_worker_written 0
STAT log_watcher_skipped 0
STAT log_watcher_sent 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT slab_global_page_pool 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evicted_active 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT crawler_items_checked 0
STAT lrutail_reflocked 0
STAT moves_to_cold 0
STAT moves_to_warm 0
STAT moves_within_lru 0
STAT direct_reclaims 0
STAT lru_bumps_dropped 0
END
Memcached-Stats

Windows中的示例

stats
STAT pid 4256
STAT uptime 3054537878
STAT time 317417903
STAT version 1.4.4-14-g9c660c0
STAT pointer_size 64
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 9
STAT bytes_written 7
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
END
Memcached服务器:
Memcached-Stats
Memcached Client
 Memcached-Stats

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

"内容整理不易,点下广告也是鼓励~"
昵称: 邮箱:
Copyright © 2020 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4