常用统计项
--------------------------
在收到无参的stats命令,server响应如下:
STAT <name> <value>\r\n
name表示统计项,value表示统计值。
响应结束符:
END\r\n
下表是返回值说明,32u表示32位无符号整型,64u表示64位无符号整型,32u:32u表示两个用冒号分开的32位无符号整型。
Name Type Meaning
----------------------------------
pid 32u server pid
uptime 32u server已经运行时间。
time 32u server当前的unix时间
version string server版本
pointer_size 32 server所在的os的指针长度(32or64)
rusage_user 32u:32u 用户累计使用的时间
(seconds:microseconds)
rusage_system 32u:32u 该server进程的累计系统时间
(seconds:microseconds)
curr_items 32u server当前存储的条目数
total_items 32u 自server启动后共存储的条目数
bytes 64u server当前用于存储数据的字节数
更多参考如下:
curr_connections 32u Number of open connections
total_connections 32u Total number of connections opened since
the server started running
connection_structures 32u Number of connection structures allocated
by the server
cmd_get 64u Cumulative number of retrieval requests
cmd_set 64u Cumulative number of storage requests
get_hits 64u Number of keys that have been requested and
found present
get_misses 64u Number of items that have been requested
and not found
evictions 64u Number of valid items removed from cache
to free memory for new items
bytes_read 64u Total number of bytes read by this server
from network
bytes_written 64u Total number of bytes sent by this server to
network
limit_maxbytes 32u Number of bytes this server is allowed to
use for storage.
threads 32u Number of worker threads requested.
(see doc/threads.txt)
Item statistics
---------------
Stats items :stats后带items参数用于请求每一个slab class 的统计信息。
Server返回格式如下
STAT items:<slabclass>:<stat> <value>\r\n
Server响应结束符:
END\r\n
Stats还可带slabs作为参数使用,stats slabs描述内存使用信息,而stats items描述更上层信息。
The following item values are defined as of writing.
Name Meaning
------------------------------
number Number of items presently stored in this class. Expired
items are not automatically excluded.
age Age of the oldest item in the LRU.
evicted Number of times an item had to be evicted from the LRU before it expired.
outofmemory Number of times the underlying slab class was unable to
store a new item. This means you are running with -M or
an eviction failed.
注意:这个命令值返回已经存在的slabs,如果cache是空的,则返回一个空的结果集。
Item size statistics
Stats sizes: 返回存储条目的长度及数量信息。
警告:该命令会锁住整个cache。该命令会查找每一个条目并计算存储尺寸。
Server响应格式:
<size> <count>\r\n
END\r\n (结束符)
'size' 存储kv的大致长度,是一个32位值.
'count' 存储kv条目的数量,32位值.
Slab statistics
---------------
返回server的每一个slabs统计信息
Server响应格式:
STAT <slabclass>:<stat> <value>\r\n
STAT <stat> <value>\r\n
END\r\n
返回参数说明
Name Meaning
------------------------------
chunk_size The amount of space each chunk uses. One item will use one chunk of the appropriate size.
chunks_per_page How many chunks exist within one page. A page by
default is one megabyte in size. Slabs are allocated per page, then broken into chunks.
total_pages Total number of pages allocated to the slab class.
total_chunks Total number of chunks allocated to the slab class.
used_chunks How many chunks have been allocated to items.
free_chunks Chunks not yet allocated to items, or freed via delete.
free_chunks_end Number of free chunks at the end of the last allocated page.
active_slabs Total number of slab classes allocated.
total_malloced Total amount of memory allocated to slab pages.