- 用法
-
CLIENT LIST [ TYPE normal | master | replica | pubsub ] [ ID client-id ] [ [ ID client-id ] ... ] [ USER username ] [ ADDR addr ] [ LADDR laddr ] [ SKIPME YES | NO ] [ MAXAGE maxage ] [ NAME name ] [ IDLE idle ] [ FLAGS flags ] [ LIB-NAME lib-name ] [ LIB-VER lib-ver ] [ DB db ] [ CAPA capa ] [ IP ip ]
- 复杂度
- O(N),其中 N 是客户端连接数
- 始于
- 2.4.0
- ACL 类别
- @connection, @admin, @dangerous, @slow
-
TYPE type
: 根据客户端类型过滤列表,其中 type 是normal
、master
、replica
和pubsub
之一。注意:被
MONITOR
命令阻塞的客户端属于normal
类型。 -
ID client-id [client-id ...]
: 返回 ID 与一个或多个client-id
参数匹配的客户端条目。 -
USER user
: 过滤列表,只包含已认证为指定用户的客户端。 -
ADDR ip:port
: 过滤列表,只包含从指定地址和端口连接的客户端。 -
LADDR ip:port
: 过滤列表,只包含连接到指定本地地址和端口的客户端。 -
SKIPME yes|no
: 过滤列表是否应跳过发出请求的客户端。yes
: 跳过发出请求的客户端。no
: 包含发出请求的客户端。
-
MAXAGE milliseconds
: 过滤列表,只包含连接时长(自客户端创建以来的时间)大于或等于指定毫秒数的客户端。注意:这实际上是最小连接时长,而不是最大连接时长。此过滤器最初添加到 CLIENT KILL 命令中,其目的是保留达到最大时长的客户端,并终止比最大时长新的客户端。
-
FLAGS flags
: 根据客户端的标志字符串过滤列表。 -
NAME name
: 过滤列表,只包含具有指定名称的客户端。 -
IDLE idle
: 只包含至少空闲了指定时间的客户端。 -
LIB-NAME lib-name
: 过滤列表,只包含使用指定库名称的客户端。 -
LIB-VER lib-ver
: 过滤列表,只包含具有指定库版本的客户端。 -
DB db
: 过滤列表,只包含具有指定数据库 ID 的客户端。 -
IP ip
: 过滤列表,只包含具有指定 IP 地址的客户端。 -
CAPA capa
: 过滤列表,只包含具有指定功能的客户端。 id
: 唯一的 64 位客户端 IDaddr
: 客户端的地址/端口laddr
: 客户端连接到的本地地址/端口(绑定地址)fd
: 对应于套接字的文件描述符name
: 客户端通过CLIENT SETNAME
设置的名称age
: 连接的总持续时间(秒)idle
: 连接的空闲时间(秒)flags
: 客户端标志(参见下文)capa
: 客户端功能(参见下文)。在 Valkey 8.1 中添加db
: 当前数据库 IDsub
: 通道订阅数psub
: 模式匹配订阅数ssub
: 分片通道订阅数。multi
: MULTI/EXEC 上下文中的命令数watch
: 此客户端当前正在监视的键的数量。在 Valkey 8.0 中添加qbuf
: 查询缓冲区长度(0 表示没有待处理的查询)qbuf-free
: 查询缓冲区的可用空间(0 表示缓冲区已满)argv-mem
: 下一个命令的不完整参数(已从查询缓冲区中提取)multi-mem
: 缓冲的多命令所占用的内存。obl
: 输出缓冲区长度oll
: 输出列表长度(当缓冲区满时,回复在此列表中排队)omem
: 输出缓冲区内存使用量tot-mem
: 此客户端在其各种缓冲区中消耗的总内存events
: 文件描述符事件(参见下文)cmd
: 执行的最后一个命令user
: 客户端的已认证用户名redir
: 当前客户端跟踪重定向的客户端 IDresp
: 客户端 RESP 协议版本。lib-name
: 客户端通过CLIENT SETINFO
设置的客户端库名称lib-version
: 客户端通过CLIENT SETINFO
设置的客户端库版本tot-net-in
: 从此客户端读取的网络输入总字节数。在 Valkey 8.0 中添加tot-net-out
: 发送到此客户端的网络输出总字节数。在 Valkey 8.0 中添加tot-cmds
: 此客户端执行的命令总数。在 Valkey 8.0 中添加
CLIENT LIST
命令以易于人类阅读的格式返回客户端连接服务器的信息和统计数据。
您可以使用一个或多个可选参数来过滤列表
过滤器可以组合使用以执行更精确的搜索。命令将通过逻辑与(AND)处理多个过滤器。
以下是字段的含义
客户端标志可以是以下组合
A: connection to be closed ASAP
b: the client is waiting in a blocking operation
c: connection to be closed after writing entire reply
d: a watched keys has been modified - EXEC will fail
e: the client is excluded from the client eviction mechanism
i: the client is waiting for a VM I/O (deprecated)
M: the client is a primary
N: no specific flag set
O: the client is a client in MONITOR mode
P: the client is a Pub/Sub subscriber
r: the client is in readonly mode against a cluster node
S: the client is a replica node connection to this instance
u: the client is unblocked
U: the client is connected via a Unix domain socket
x: the client is in a MULTI/EXEC context
t: the client enabled keys tracking in order to perform client side caching
T: the client will not touch the LRU/LFU of the keys it accesses
R: the client tracking target client is invalid
B: the client enabled broadcast tracking mode
I: the client is an import source
客户端功能可以是
r: the client can handle redirect messages
文件描述符事件可以是
r: the client socket is readable (event loop)
w: the client socket is writable (event loop)
示例
CLIENT LIST TYPE normal USER admin MAXAGE 5000 ID 1234 5678
id=1234 addr=127.0.0.1:64000 laddr=127.0.0.1:6379 fd=5 name= age=600 idle=300 flags= db=0 sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 tot-mem=1024 events=r cmd=client|list user=default redir=-1 resp=2 lib-name= lib-ver=
id=5678 addr=127.0.0.1:64001 laddr=127.0.0.1:6379 fd=6 name= age=900 idle=450 flags= db=0 sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 tot-mem=2048 events=r cmd=client|list user=default redir=-1 resp=2 lib-name= lib-ver=
备注
新字段会定期添加以用于调试目的。其中一些在将来可能会被移除。使用此命令的版本安全的 Valkey 客户端应相应地解析输出(即优雅地处理缺失字段,跳过未知字段)。
RESP2/RESP3 回复
批量字符串回复:关于客户端连接的信息和统计数据。
历史
版本 | 变更 |
---|---|
2.8.12 | 添加了唯一的客户端 |
5.0.0 | 添加了可选的 |
6.0.0 | 添加了 |
6.2.0 | 添加了 |
7.0.0 | 添加了 |
7.0.3 | 添加了 |
8.0.0 | 将 |
8.1.0 | 添加了 USER、ADDR、LADDR、SKIPME 和 MAXAGE 过滤器。 |
9.0.0 | 添加了 NAME、IDLE、FLAGS、LIB-NAME、LIB-VER、DB、CAPA 和 IP 过滤器。 |